Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

ark::AsyncConsumer< T, SourceQueuePolicy > Class Template Reference

#include <AsyncConsumer.h>

List of all members.

Public Types

typedef SourceQueuePolicy<
T >::IQueueType 
SourceQueue

Public Member Functions

 AsyncConsumer ()
virtual ~AsyncConsumer ()
virtual void startConsuming ()
virtual void stopConsuming (bool wait=false)
bool isConsuming () const
bool scheduleConsumption (typename boost::add_reference< T >::type t)
bool setConsumptionWaitTime (unsigned secs, unsigned nanos)
boost::tuple< unsigned, unsigned > consumptionWaitTime () const
bool consumeLoopOnce ()
void consumeLoop ()
virtual void consume (typename boost::add_reference< T >::type msg, SourceQueue &)=0
virtual void whileNotConsuming ()
virtual void consumerDone ()

Private Types

typedef boost::shared_ptr<
boost::thread > 
ThreadHandle
typedef boost::mutex::scoped_lock scoped_lock

Private Attributes

boost::mutex _exitConsumptionMutex
volatile bool _exitConsumptionFlag
ThreadHandle _consumerThread
unsigned _consWaitSecs
unsigned _consWaitNanos
unsigned _consNewSecs
unsigned _consNewNanos
Atomic< bool > _consChangeWait

template<typename T, template< class > class SourceQueuePolicy = ARK_ASYNC_CONSUMER_DEFAULT_SOURCE_QUEUE_POLICY>
class ark::AsyncConsumer< T, SourceQueuePolicy >


Member Typedef Documentation

template<typename T, template< class > class SourceQueuePolicy = ARK_ASYNC_CONSUMER_DEFAULT_SOURCE_QUEUE_POLICY>
typedef boost::mutex::scoped_lock ark::AsyncConsumer< T, SourceQueuePolicy >::scoped_lock [private]
 

Reimplemented in ark::AsyncNotifier< Notification, Observer_t, Observed_t >.

template<typename T, template< class > class SourceQueuePolicy = ARK_ASYNC_CONSUMER_DEFAULT_SOURCE_QUEUE_POLICY>
typedef SourceQueuePolicy<T>::IQueueType ark::AsyncConsumer< T, SourceQueuePolicy >::SourceQueue
 

Reimplemented in ark::AsyncNotifier< Notification, Observer_t, Observed_t >.

template<typename T, template< class > class SourceQueuePolicy = ARK_ASYNC_CONSUMER_DEFAULT_SOURCE_QUEUE_POLICY>
typedef boost::shared_ptr<boost::thread> ark::AsyncConsumer< T, SourceQueuePolicy >::ThreadHandle [private]
 


Constructor & Destructor Documentation

template<typename T, template< class > class SourceQueuePolicy = ARK_ASYNC_CONSUMER_DEFAULT_SOURCE_QUEUE_POLICY>
ark::AsyncConsumer< T, SourceQueuePolicy >::AsyncConsumer  )  [inline]
 

template<typename T, template< class > class SourceQueuePolicy = ARK_ASYNC_CONSUMER_DEFAULT_SOURCE_QUEUE_POLICY>
virtual ark::AsyncConsumer< T, SourceQueuePolicy >::~AsyncConsumer  )  [inline, virtual]
 


Member Function Documentation

template<typename T, template< class > class SourceQueuePolicy = ARK_ASYNC_CONSUMER_DEFAULT_SOURCE_QUEUE_POLICY>
virtual void ark::AsyncConsumer< T, SourceQueuePolicy >::consume typename boost::add_reference< T >::type  msg,
SourceQueue
[pure virtual]
 

consume Override this function to handle the consumed message.

Parameters:
msg The message to consume

template<typename T, template< class > class SourceQueuePolicy = ARK_ASYNC_CONSUMER_DEFAULT_SOURCE_QUEUE_POLICY>
void ark::AsyncConsumer< T, SourceQueuePolicy >::consumeLoop  )  [inline]
 

consumeLoop Runs the consumer loop continuously, until _exitConsumptionFlag is set to true.

See also:
runLoopOnce()

stop()

template<typename T, template< class > class SourceQueuePolicy = ARK_ASYNC_CONSUMER_DEFAULT_SOURCE_QUEUE_POLICY>
bool ark::AsyncConsumer< T, SourceQueuePolicy >::consumeLoopOnce  )  [inline]
 

consumeLoopOnce Runs the consumer loop once, checking for messages and dispatching them. Notice that this function will block until a message is dispatched or _exitFlag is changed.

Returns:
The value of _exitConsumptionFlag
See also:
consumeLoop()

template<typename T, template< class > class SourceQueuePolicy = ARK_ASYNC_CONSUMER_DEFAULT_SOURCE_QUEUE_POLICY>
virtual void ark::AsyncConsumer< T, SourceQueuePolicy >::consumerDone  )  [inline, virtual]
 

consumerDone Override this to perform some tasks right before the consumer thread exits.

template<typename T, template< class > class SourceQueuePolicy = ARK_ASYNC_CONSUMER_DEFAULT_SOURCE_QUEUE_POLICY>
boost::tuple<unsigned, unsigned> ark::AsyncConsumer< T, SourceQueuePolicy >::consumptionWaitTime  )  const [inline]
 

consumptionWaitTime

Returns:
The max amount of time to wait for new messages to consume in a boost::tuple, with the the first element being seconds, and the second nanoseconds

template<typename T, template< class > class SourceQueuePolicy = ARK_ASYNC_CONSUMER_DEFAULT_SOURCE_QUEUE_POLICY>
bool ark::AsyncConsumer< T, SourceQueuePolicy >::isConsuming  )  const [inline]
 

isConsuming

Returns:
True if the consumer thread is running
See also:
startConsuming()

stopConsuming()

template<typename T, template< class > class SourceQueuePolicy = ARK_ASYNC_CONSUMER_DEFAULT_SOURCE_QUEUE_POLICY>
bool ark::AsyncConsumer< T, SourceQueuePolicy >::scheduleConsumption typename boost::add_reference< T >::type  t  )  [inline]
 

scheduleConsumption Schedules a consumption target for the consumer thread to process in the future, and returns whether it was scheduled or not immediately.

Parameters:
t The target to consume

template<typename T, template< class > class SourceQueuePolicy = ARK_ASYNC_CONSUMER_DEFAULT_SOURCE_QUEUE_POLICY>
bool ark::AsyncConsumer< T, SourceQueuePolicy >::setConsumptionWaitTime unsigned  secs,
unsigned  nanos
[inline]
 

setConsumptionWaitTime Sets the amount of time that the consumer will wait, before doing idle work or checking the source queue for more data.

Parameters:
secs The amount of seconds to wait
nanos The amount of nanoseconds to wait
Returns:
True if a change was made, or succesfully scheduled for later

template<typename T, template< class > class SourceQueuePolicy = ARK_ASYNC_CONSUMER_DEFAULT_SOURCE_QUEUE_POLICY>
virtual void ark::AsyncConsumer< T, SourceQueuePolicy >::startConsuming  )  [inline, virtual]
 

startConsuming Starts the consumer run loop, or cancels a pending exit. Always invoke this at the end of a subclasses override.

See also:
stopConsuming()

isConsuming()

consumptionLoop()

template<typename T, template< class > class SourceQueuePolicy = ARK_ASYNC_CONSUMER_DEFAULT_SOURCE_QUEUE_POLICY>
virtual void ark::AsyncConsumer< T, SourceQueuePolicy >::stopConsuming bool  wait = false  )  [inline, virtual]
 

stopConsuming Stops a running consumer thread, blocking until the thread joins, if the 'wait' flag is set. Always invoke this at the end of a subclasses override.

See also:
start()

isRunning()

template<typename T, template< class > class SourceQueuePolicy = ARK_ASYNC_CONSUMER_DEFAULT_SOURCE_QUEUE_POLICY>
virtual void ark::AsyncConsumer< T, SourceQueuePolicy >::whileNotConsuming  )  [inline, virtual]
 

whileNotConsuming Override this function to perform tasks while the consumer is waiting for messages.


Member Data Documentation

template<typename T, template< class > class SourceQueuePolicy = ARK_ASYNC_CONSUMER_DEFAULT_SOURCE_QUEUE_POLICY>
Atomic<bool> ark::AsyncConsumer< T, SourceQueuePolicy >::_consChangeWait [private]
 

template<typename T, template< class > class SourceQueuePolicy = ARK_ASYNC_CONSUMER_DEFAULT_SOURCE_QUEUE_POLICY>
unsigned ark::AsyncConsumer< T, SourceQueuePolicy >::_consNewNanos [private]
 

template<typename T, template< class > class SourceQueuePolicy = ARK_ASYNC_CONSUMER_DEFAULT_SOURCE_QUEUE_POLICY>
unsigned ark::AsyncConsumer< T, SourceQueuePolicy >::_consNewSecs [private]
 

template<typename T, template< class > class SourceQueuePolicy = ARK_ASYNC_CONSUMER_DEFAULT_SOURCE_QUEUE_POLICY>
ThreadHandle ark::AsyncConsumer< T, SourceQueuePolicy >::_consumerThread [private]
 

template<typename T, template< class > class SourceQueuePolicy = ARK_ASYNC_CONSUMER_DEFAULT_SOURCE_QUEUE_POLICY>
unsigned ark::AsyncConsumer< T, SourceQueuePolicy >::_consWaitNanos [private]
 

template<typename T, template< class > class SourceQueuePolicy = ARK_ASYNC_CONSUMER_DEFAULT_SOURCE_QUEUE_POLICY>
unsigned ark::AsyncConsumer< T, SourceQueuePolicy >::_consWaitSecs [private]
 

template<typename T, template< class > class SourceQueuePolicy = ARK_ASYNC_CONSUMER_DEFAULT_SOURCE_QUEUE_POLICY>
volatile bool ark::AsyncConsumer< T, SourceQueuePolicy >::_exitConsumptionFlag [private]
 

template<typename T, template< class > class SourceQueuePolicy = ARK_ASYNC_CONSUMER_DEFAULT_SOURCE_QUEUE_POLICY>
boost::mutex ark::AsyncConsumer< T, SourceQueuePolicy >::_exitConsumptionMutex [private]
 


The documentation for this class was generated from the following file:
Generated on Tue Sep 6 14:54:39 2005 for Arkonnekt Sound by  doxygen 1.4.4