C++
C#
VB
JScript
All

# condition_mutex

Copyright (C) 2005 IENT-RWTH Aachen

Gathers a spin_mutex and a condition together

Groups

Multithreading Functions
acquire | Waits until a lock can be acquired
release | Releases the lock
signal | Restarts one of the threads that are waiting on the condition variable
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