Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

atoms::Once Class Reference
[Multi-threaded programming]

#include <once.hh>

Collaboration diagram for atoms::Once:

Collaboration graph
[legend]
List of all members.

Detailed Description

Performs an action exactly once despite invocations in multiple threads.

This doesn't use pthread_once because that isn't flexible to support calling a slot. Instead, it just does it with a bool and a Mutex.

Definition at line 24 of file once.hh.

Public Member Functions

 Once ()
 Initializes data.

void operator() (const boost::function< void()> &action)
 Performs the action iff none has been performed through this object before.


Private Attributes

bool done
 True iff the action has been performed.

Mutex m
 Mutex to avoid race condition.


Constructor & Destructor Documentation

atoms::Once::Once  )  [inline]
 

Initializes data.

Definition at line 27 of file once.hh.

References done.


Member Function Documentation

void Once::operator() const boost::function< void()> &  action  ) 
 

Performs the action iff none has been performed through this object before.

If an exception is thrown, it will be as if the action was not performed.

Definition at line 17 of file once.cc.

References done, and m.


Member Data Documentation

bool atoms::Once::done [private]
 

True iff the action has been performed.

Definition at line 38 of file once.hh.

Referenced by Once(), and operator()().

Mutex atoms::Once::m [private]
 

Mutex to avoid race condition.

Definition at line 41 of file once.hh.

Referenced by operator()().


The documentation for this class was generated from the following files:
Generated on Wed Jun 15 01:20:54 2005 for atoms++ by doxygen 1.3.5