public class QueueProcessingThreadSender extends QueueProcessingThread<String> implements MessageSendingQueue
MessageSendingQueue
using QueueProcessingThread
.Thread.State, Thread.UncaughtExceptionHandler
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Constructor and Description |
---|
QueueProcessingThreadSender(Client client,
String name)
Constructs the sending queue.
|
Modifier and Type | Method and Description |
---|---|
void |
beginSending(Consumer<String> consumer)
Starts sending messages to the given consumer.
|
protected boolean |
checkReady(String message)
Checks if the message can be sent yet, or at all.
|
protected void |
cleanup(Queue<String> remainingQueue)
This method is called after the thread has been interrupted.
|
protected Client |
getClient()
Gets the client.
|
Optional<Consumer<String>> |
getConsumer()
Gets the queue's currently set consumer.
|
void |
pause()
Pauses message sending.
|
protected void |
processElement(String message)
Processes an element from the queue.
|
Queue<String> |
shutdown()
Closes down shop, interrupts all threads.
|
contains, getQueue, queue, run
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
contains, queue
protected void processElement(@Nonnull String message)
QueueProcessingThread
processElement
in class QueueProcessingThread<String>
message
- next element from the queueprotected boolean checkReady(@Nonnull String message)
message
- the message to be sentprotected final void cleanup(@Nonnull Queue<String> remainingQueue)
QueueProcessingThread
cleanup
in class QueueProcessingThread<String>
remainingQueue
- the queuepublic void beginSending(@Nonnull Consumer<String> consumer)
MessageSendingQueue
beginSending
in interface MessageSendingQueue
consumer
- the consumer to consume@Nonnull public Optional<Consumer<String>> getConsumer()
MessageSendingQueue
getConsumer
in interface MessageSendingQueue
public void pause()
MessageSendingQueue
pause
in interface MessageSendingQueue
@Nonnull public Queue<String> shutdown()
MessageSendingQueue
shutdown
in interface MessageSendingQueue
Copyright © 2013–2019 Kitteh. All rights reserved.