public class TaskWorker
extends java.lang.Object
implements java.lang.Runnable
SSLEngine
that is associated with a
SecureSocket
. The worker sequentially processes tasks that need
to be completed, in a FIFO fashion, notifying the associated
TaskListener
once they have been completed. The TaskWorker
is
otherwise waiting for incoming tasks via the addSocket(SecureSocket)
method.
Constructor and Description |
---|
TaskWorker(TaskListener listener)
Create a
TaskWorker instance with a single TaskListener
reference. |
Modifier and Type | Method and Description |
---|---|
void |
addSocket(SecureSocket socket)
Add a
SecureSocket with an underlying
SSLEngine that requires a task to be run. |
boolean |
isRunning()
Check whether the
TaskWorker is running. |
void |
run()
The run() method of the
TaskWorker . |
void |
setRunning(boolean running)
Set the running status of the
TaskWorker . |
public TaskWorker(TaskListener listener)
TaskWorker
instance with a single TaskListener
reference. The TaskListener
is notified whenever any task has
finished being processed by the TaskWorker.listener
- The TaskListener
to be notified of completed
taskspublic void addSocket(SecureSocket socket)
SecureSocket
with an underlying
SSLEngine
that requires a task to be run. Tasks are
run in a FIFO queue according to order of socket insertion.socket
- The SecureSocket that requires a task to be runpublic void run()
TaskWorker
. Here, sequential processing
of SSLEngine
tasks that need to be completed is
done in a FIFO fashion, notifying the associated TaskListener
once they have been completed. The TaskWorker
is otherwise
waiting for incoming tasks via the addSocket(SecureSocket)
method.run
in interface java.lang.Runnable
public boolean isRunning()
TaskWorker
is running.public void setRunning(boolean running)
TaskWorker
. If the running status
of the worker is set to false, the TaskWorker is interrupted (if waiting
for a task) in order to cleanly shutdown.running
- Whether the TaskWorker should run or not