C++
C#
VB
JScript
All

Class condition_mutex


Copyright (C) 2005 IENT-RWTH Aachen

Gathers a spin_mutex and a condition together

Groups

Multithreading Functions
Method acquire

Waits until a lock can be acquired

Method release

Releases the lock

Method signal

Restarts one of the threads that are waiting on the condition variable

Method wait

Waits for the condition variable to be signaled

Example

int x,y;
typedef gmt::condition_mutex mutex_type;
mutex_type cond;

//First thread
{
  mutex_type::scoped_lock lock(cond);
  while (x<=y) cond.wait();
  // operate on x and y
}

// Second thread
{
  mutex_type::scoped_lock lock(cond);
  // modify x and y
  if (x>y) cond.signal();
}

See Also

condition, mutex, spin_mutex