|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.felix.eventadmin.impl.tasks.SyncDeliverTasks
public class SyncDeliverTasks
This class does the actual work of the synchronous event delivery.
It serves two purposes, first it is used to select the appropriate action depending on whether the sending thread is the asynchronous, the synchronous, or an unrelated thread. Second, it will set up a given dispatch task with its ThreadPool in a way that it is associated with a DeliverTask that will push given handler tasks to the queue and then wait for the tasks to be completed.
In other words if an unrelated thread is used to send a synchronous event it is blocked until the event is send (or a timeout occurs), if an asynchronous thread is used its handover callback is called in order to spin-off a new asynchronous delivery thread and the former is blocked until the events are delivered and then released (or returned to its thread pool), if a synchronous thread is used its task is disabled, the events are pushed to the queue and the threads continuous with the delivery of the new events (as per spec). Once the new events are done the thread wakes-up the disabled task and resumes to execute it.Note that in case of a timeout while a task is disabled the thread is released and we spin-off a new thread that resumes the disabled task hence, this is the only place were we break the semantics of the synchronous delivery. While the only one to notice this is the timed-out handler - it is the fault of this handler too (i.e., it blocked the dispatch for to long) but since it will not receive events anymore it will not notice this semantic difference except that it might not see events it already sent before.
Constructor Summary | |
---|---|
SyncDeliverTasks(TaskQueue queue,
ThreadPool pool)
|
Method Summary | |
---|---|
DeliverTask |
createTask()
This will select the appropriate action depending on whether the sending thread is the asynchronous, the synchronous, or an unrelated thread. |
void |
execute(DispatchTask task)
Set up a given dispatch task with its ThreadPool in a way that it is associated with a DeliverTask that will push given handler tasks to the queue and then wait for the tasks to be completed. |
void |
execute(HandlerTask[] tasks)
This blocks an unrelated thread used to send a synchronous event until the event is send (or a timeout occurs). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SyncDeliverTasks(TaskQueue queue, ThreadPool pool)
queue
- The synchronous event queuepool
- The thread pool used to spin-off new threads and associate
callbacks with tasksMethod Detail |
---|
public DeliverTask createTask()
createTask
in interface DeliverTasks
DeliverTasks.createTask()
public void execute(HandlerTask[] tasks)
execute
in interface DeliverTask
tasks
- The event handler dispatch tasks to executeDeliverTask.execute(org.apache.felix.eventadmin.impl.tasks.HandlerTask[])
public void execute(DispatchTask task)
execute
in interface HandoverTask
task
- The task to set-upHandoverTask.execute(org.apache.felix.eventadmin.impl.tasks.DispatchTask)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |