class Mutex

A mutex More...

Full nameArts::Mutex
Definition#include <arts/thread.h>
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods


Detailed Description

A mutex

To protect a critical section, you can use a mutex, which will ensure that only one thread at a time can lock it. Here is an example for a thread-safe random number generator:


 class RandomGenerator {
   Arts::Mutex mutex;
   long seed;
 public:
   long get() {
     mutex.lock();
     // do complicated calculation with seed here
     mutex.unlock();
     return seed;
   }
 };

inline  Mutex ()

constructor

 ~Mutex ()

[virtual]

destructor

inline void  lock ()

locks the mutex

inline void  unlock ()

unlocks the mutex


Generated by: stefan@stefan on Sat Feb 24 19:11:23 2001, using kdoc 2.0a47.