mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-14 02:33:51 +02:00
13 lines
404 B
C
13 lines
404 B
C
|
#pragma once
|
||
|
#include <boost/thread.hpp>
|
||
|
template <typename T> struct CondSh
|
||
|
{
|
||
|
T data;
|
||
|
boost::condition_variable cond;
|
||
|
boost::mutex mx;
|
||
|
CondSh(){};
|
||
|
CondSh(T t){data = t;};
|
||
|
void set(T t){mx.lock();data=t;mx.unlock();}; //set data
|
||
|
void setn(T t){mx.lock();data=t;mx.unlock();cond.notify_all();}; //set data and notify
|
||
|
T get(){boost::unique_lock<boost::mutex> lock(mx); return data;};
|
||
|
};
|