PTLib
Version 2.18.8
|
Asynchronous PNotifier class. More...
#include <notifier_ext.h>
Public Member Functions | |
PAsyncNotifierTarget () | |
virtual | ~PAsyncNotifierTarget () |
bool | AsyncNotifierExecute (const PTimeInterval &wait=0) |
Execute any notifications queued. More... | |
virtual void | AsyncNotifierSignal () |
Signal the target that there are notifications pending. More... | |
Asynchronous PNotifier class.
This is a notification mechanism disconnects the caller from the target via a queue. The primary use would be to assure that the target class instance is only accesses via a specific thread.
A notification target class must derive from PAsyncNotifierTarget, usually as a multiple inheritance, which will associate a a queue with the specific class instance.
As well as deriving from PAsyncNotifierTarget class, the notifier functions must be declared using the PDECLARE_ASYNC_NOTIFIER rather than the usual PDECLARE_NOTIFIER macro.
PAsyncNotifierTarget::PAsyncNotifierTarget | ( | ) |
|
virtual |
bool PAsyncNotifierTarget::AsyncNotifierExecute | ( | const PTimeInterval & | wait = 0 | ) |
Execute any notifications queued.
The target must call this function for the asynchronous notifications to occur.
wait | Time to wait for a notification |
|
virtual |
Signal the target that there are notifications pending.
The infrastructure will call this virtual from a random thread to indicate that a notification has been queued. What happens is applicaation dependent, but typically this would indicate to a main thread that it is time to call AsyncNotifierExecute(). For example for a GUI, this would post a message to the windowing system. That message is captured in teh GUI thread and AsyncNotifierExecute() called.