qpid::sys::Serializer< Task > Class Template Reference

Execute tasks sequentially, queuing tasks when necessary to ensure only one thread at a time executes a task and tasks are executed in order. More...

#include <Serializer.h>

Inheritance diagram for qpid::sys::Serializer< Task >:

Inheritance graph
[legend]
Collaboration diagram for qpid::sys::Serializer< Task >:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Serializer (bool immediate=true)
 Start a serializer.
void execute (Task &task)
 Task may be executed immediately in the calling thread if there are no other tasks pending or executing and the "immediate" paramater to the constructor was true.
void dispatch ()
 Execute pending tasks sequentially in calling thread.


Detailed Description

template<class Task>
class qpid::sys::Serializer< Task >

Execute tasks sequentially, queuing tasks when necessary to ensure only one thread at a time executes a task and tasks are executed in order.

Task is a void returning 0-arg functor. It must not throw exceptions.

Note we deliberately do not use boost::function as the task type because copying a boost::functor allocates the target object on the heap.


Constructor & Destructor Documentation

template<class Task>
qpid::sys::Serializer< Task >::Serializer ( bool  immediate = true  )  [inline]

Start a serializer.

Parameters:
immediate Allow execute() to execute a task immediatly in the current thread.


Member Function Documentation

template<class Task>
void qpid::sys::Serializer< Task >::execute ( Task &  task  )  [inline]

Task may be executed immediately in the calling thread if there are no other tasks pending or executing and the "immediate" paramater to the constructor was true.

Otherwise task will be enqueued for execution by a dispatch thread.

References qpid::sys::Serializer< Task >::dispatch(), qpid::sys::SerializerBase::DISPATCHING, qpid::sys::SerializerBase::EXECUTING, qpid::sys::SerializerBase::IDLE, and qpid::sys::SerializerBase::SHUTDOWN.

template<class Task>
void qpid::sys::Serializer< Task >::dispatch (  )  [inline, virtual]

Execute pending tasks sequentially in calling thread.

Drains the task queue and returns, does not block for more tasks.

Exceptions:
ShutdownException if the serializer is being destroyed.

Implements qpid::sys::SerializerBase.

References qpid::sys::SerializerBase::DISPATCHING, qpid::sys::SerializerBase::IDLE, and qpid::sys::SerializerBase::SHUTDOWN.

Referenced by qpid::sys::Serializer< Task >::execute().


The documentation for this class was generated from the following file:

Generated on Thu May 15 22:24:58 2008 for Qpid by  doxygen 1.5.5