Glib::Dispatcher Class Reference
[Threads]

Signal class for inter-thread communication. More...

Collaboration diagram for Glib::Dispatcher:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Dispatcher ()
 Create new Dispatcher instance using the default main context.
 Dispatcher (const Glib::RefPtr< MainContext >& context)
 Create new Dispatcher instance using an arbitrary main context.
 ~Dispatcher ()
void emit ()
void operator() ()
sigc::connection connect (const sigc::slot< void >&slot)

Detailed Description

Signal class for inter-thread communication.

Glib::Dispatcher works similar to sigc::signal<void>. But unlike normal signals, the notification happens asynchronously through a pipe. This is a simple and efficient way of communicating between threads, and especially useful in a thread model with a single GUI thread.

No mutex locking is involved, apart from the operating system's internal I/O locking. That implies some usage rules:

Notes about performance:

Using Glib::Dispatcher on Windows:

Glib::Dispatcher also works on win32-based systems. Unfortunately though, the implementation cannot use a pipe on win32 and therefore does have to lock a mutex on emission, too. However, the impact on performance is likely minor and the notification still happens asynchronously. Apart from the additional lock the behavior matches the Unix implementation.

Examples:

thread/dispatcher.cc.


Constructor & Destructor Documentation

Glib::Dispatcher::Dispatcher (  ) 

Create new Dispatcher instance using the default main context.

Exceptions:
Glib::FileError 
Glib::Dispatcher::Dispatcher ( const Glib::RefPtr< MainContext >&  context  )  [explicit]

Create new Dispatcher instance using an arbitrary main context.

Exceptions:
Glib::FileError 
Glib::Dispatcher::~Dispatcher (  ) 

Member Function Documentation

sigc::connection Glib::Dispatcher::connect ( const sigc::slot< void > &  slot  ) 
void Glib::Dispatcher::emit (  ) 
void Glib::Dispatcher::operator() (  ) 

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

Generated on Sat Jan 2 23:07:03 2010 for glibmm by  doxygen 1.6.1