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(@NonNull Client client,
@NonNull String name)
Constructs the sending queue.
|
Modifier and Type | Method and Description |
---|---|
void |
beginSending(@NonNull Consumer<String> consumer)
Starts sending messages to the given consumer.
|
protected boolean |
checkReady(@NonNull String message)
Checks if the message can be sent yet, or at all.
|
protected void |
cleanup(@NonNull Queue<String> remainingQueue)
This method is called after the thread has been interrupted.
|
protected @NonNull Client |
getClient()
Gets the client.
|
@NonNull Optional<Consumer<String>> |
getConsumer()
Gets the queue's currently set consumer.
|
void |
pause()
Pauses message sending.
|
protected void |
processElement(@NonNull String message)
Processes an element from the queue.
|
@NonNull 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 queueprotected @NonNull Client getClient()
public void beginSending(@NonNull Consumer<String> consumer)
MessageSendingQueue
beginSending
in interface MessageSendingQueue
consumer
- the consumer to consumepublic @NonNull Optional<Consumer<String>> getConsumer()
MessageSendingQueue
getConsumer
in interface MessageSendingQueue
public void pause()
MessageSendingQueue
pause
in interface MessageSendingQueue
public @NonNull Queue<String> shutdown()
MessageSendingQueue
shutdown
in interface MessageSendingQueue
Copyright © 2013–2021 Kitteh. All rights reserved.