public final class Worker extends WorkerNIO
LAN_BUFFER_SIZE
Constructor and Description |
---|
Worker(SessionInfo sessionInfo)
Creates an instance of the Worker queue.
|
Modifier and Type | Method and Description |
---|---|
boolean |
dispose()
Disposes of the worker.
|
SessionInfo |
getSessionInfo()
Get the SessionInfo from the Worker.
|
boolean |
isWorkerThread()
Checks if the calling thread is the worker thread or not.
|
boolean |
post(Runnable runnable)
Helper method to post a runnable for execution.
|
boolean |
post(WorkerTask<?,?,?> task)
Posts a task for execution at a later stage.
|
boolean |
postAndWait(WorkerTask<?,?,?> task)
Posts a task for execution at a later stage and waits for it's completion.
|
boolean |
postModalWait(WorkerTask<?,?,?> task)
Posts a task for execution at a later stage and waits for it's completion
when a call to
relaseModal(modalID,result) is called. |
void |
process()
Starts processing the worker queue operations.
|
protected boolean |
processOnce()
Processes once a single write-read-execute operation.
|
protected boolean |
processSelectorKeys(boolean now)
Process selector keys.
|
boolean |
releaseModal(int modalID,
Object result)
Releases a modal waiting task and sets its result.
|
boolean |
runNowOrPost(Runnable runnable)
Helper method to perform the execution of the runnable now IF
the current thread is the worker thread, otherwise a post is
done.
|
checkDisposed, isDisposed, register, registerTimeoutHandler, unregisterTimeoutHandler, wakeupSelector
public Worker(SessionInfo sessionInfo) throws IOException
sessionInfo
- The SessionInfo for an EndPoint, null for server or (single) main worker (for Eclipse case).IOException
- If an I/O error occurs.public SessionInfo getSessionInfo()
protected boolean processSelectorKeys(boolean now) throws IOException
processSelectorKeys
in class WorkerNIO
now
- Checking of selectors now or when queue is empty.IOException
- For I/O exceptions.public void process()
public boolean isWorkerThread()
protected boolean processOnce()
processOnce
in class WorkerNIO
public boolean dispose()
public boolean post(Runnable runnable)
runnable
- The runnable.public boolean post(WorkerTask<?,?,?> task)
task
- The task to post, non-null.IllegalStateException
- If the task already has been posted to a worker.public boolean postAndWait(WorkerTask<?,?,?> task) throws InterruptedException
execute
method.task
- The task to post, non-null.InterruptedException
- If the task was interrupted.IllegalStateException
- If the task already has been posted to a worker.public boolean runNowOrPost(Runnable runnable)
runnable
- The runnable.IllegalStateException
- If the worker is disposed of.public boolean postModalWait(WorkerTask<?,?,?> task) throws InterruptedException
relaseModal(modalID,result)
is called.task
- The task to post, non-null.InterruptedException
- If the task was interrupted.IllegalStateException
- If the task already has been posted to a worker.public boolean releaseModal(int modalID, Object result)
modalID
- The modal ID of the task.result
- The result to set for the task.IllegalStateException
- If the task is already released.iizi® is a registered trademark of Mindus SARL. © Copyright Mindus SARL, 2020. All rights reserved.