org.apache.felix.eventadmin.impl.tasks
Class SyncDeliverTasks

java.lang.Object
  extended by org.apache.felix.eventadmin.impl.tasks.SyncDeliverTasks
All Implemented Interfaces:
DeliverTask

public class SyncDeliverTasks
extends Object
implements DeliverTask

This class does the actual work of the synchronous event delivery. This is the heart of the event delivery. If an event is delivered without timeout handling, the event is directly delivered using the calling thread. If timeout handling is enabled, a new thread is taken from the thread pool and this thread is used to deliver the event. The calling thread is blocked until either the deliver is finished or the timeout occurs.

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. If during an event delivery a new event should be delivered from within the event handler, the timeout handler is stopped for the delivery time of the inner event!

Author:
Felix Project Team

Constructor Summary
SyncDeliverTasks(DefaultThreadPool pool, long timeout, String[] ignoreTimeout)
          Construct a new sync deliver tasks.
 
Method Summary
 void execute(HandlerTask[] tasks)
          This blocks an unrelated thread used to send a synchronous event until the event is send (or a timeout occurs).
 void update(long timeout, String[] ignoreTimeout)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SyncDeliverTasks

public SyncDeliverTasks(DefaultThreadPool pool,
                        long timeout,
                        String[] ignoreTimeout)
Construct a new sync deliver tasks.

Parameters:
pool - The thread pool used to spin-off new threads.
timeout - The timeout for an event handler, 0 = disabled
Method Detail

update

public void update(long timeout,
                   String[] ignoreTimeout)

execute

public void execute(HandlerTask[] tasks)
This blocks an unrelated thread used to send a synchronous event until the event is send (or a timeout occurs).

Specified by:
execute in interface DeliverTask
Parameters:
tasks - The event handler dispatch tasks to execute
See Also:
DeliverTask.execute(HandlerTask[])


Copyright © 2011 Apache Software Foundation. All Rights Reserved.