#include <AsyncNotifier.h>
Inheritance diagram for ark::AsyncNotifier< Notification, Observer_t, Observed_t >:
Public Member Functions | |
void | receiveNotification (Notification const ¬e) |
void | consume (Notification ¬e, SourceQueue &q) |
void | addObserver (boost::shared_ptr< Observer_t > const &obj) |
void | addObserver (boost::shared_ptr< Observer_t > const &obj, Observed_t const &obs) |
void | addObserver (boost::shared_ptr< Observer_t > const &obj, Notification const ¬e) |
void | removeObserver (boost::shared_ptr< Observer_t > &obj) |
void | removeObserver (boost::shared_ptr< Observer_t > &obj, Observed_t const &observed) |
void | removeObserver (boost::shared_ptr< Observer_t > &obj, Notification const ¬e) |
bool | isObserving (boost::shared_ptr< Observer_t > const &obj) |
void | setMultithreaded (bool mt) |
bool | isMultithreaded () const |
Protected Types | |
typedef boost::mutex::scoped_lock | scoped_lock |
Private Types | |
typedef Notifier< Notification, Observer_t, Observed_t > | note_super |
typedef AsyncConsumer< Notification >::SourceQueue | SourceQueue |
Private Member Functions | |
void | _dispatchNotification (Notification note) |
Runs in own thread. | |
Private Attributes | |
boost::mutex | _allMutex |
boost::thread_group | _distributors |
Atomic< bool > | _multithreads |
There are two modes to determine how asynchronously the notifications are distributed. The 'normal' mode simply distributes notifications to all registered observers in the consume() override. Remember that as an AsyncConsumer, our runloop is already in it's own dedicated thread, and thus normal mode is usually sufficient. However for fringe cases there is also the multithreaded mode, where each received notification is distributed in it's own temporary thread. Note that despite using boost::thread_group there will be a substantial cost in creating worker threads sometimes.
Because the observers are stored as weak references, there is no need to unregister an observer before it is destroyed.
|
|
|
Reimplemented from ark::AsyncConsumer< Notification >. |
|
Reimplemented from ark::AsyncConsumer< Notification >. |
|
Runs in own thread.
|
|
Reimplemented from ark::Notifier< Notification, Observer_t, Observed_t >. |
|
Reimplemented from ark::Notifier< Notification, Observer_t, Observed_t >. |
|
Reimplemented from ark::Notifier< Notification, Observer_t, Observed_t >. |
|
consume Override of AsyncConsumer, distributes the notification to observers, or schedules delivery on a worker thread.
|
|
isMultithreaded
|
|
isObserving
Reimplemented from ark::Notifier< Notification, Observer_t, Observed_t >. |
|
receiveNotification Override of Observer_t sends the notification to all registered observers.
Reimplemented from ark::Notifier< Notification, Observer_t, Observed_t >. |
|
Reimplemented from ark::Notifier< Notification, Observer_t, Observed_t >. |
|
Reimplemented from ark::Notifier< Notification, Observer_t, Observed_t >. |
|
removeObserver Removes an observer from this notifier. All registrations will be removed.
Reimplemented from ark::Notifier< Notification, Observer_t, Observed_t >. |
|
setMultithreaded Sets whether the notifier should deliver each notification in it's own thread or not.
|
|
|
|
|
|
|