PTLib  Version 2.14.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PAsyncNotifierTarget Class Reference

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

PAsyncNotifierTarget::PAsyncNotifierTarget ( )
virtual PAsyncNotifierTarget::~PAsyncNotifierTarget ( )
virtual

Member Function Documentation

bool PAsyncNotifierTarget::AsyncNotifierExecute ( const PTimeInterval wait = 0)

Execute any notifications queued.

The target must call this function for the asynchronous notifications to occur.

Returns
true if a notification was executed.
Parameters
waitTime to wait for a notification
virtual void PAsyncNotifierTarget::AsyncNotifierSignal ( )
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.


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