1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00
vcmi/lib/CondSh.h
Michał W. Urbańczyk a15ffb06e6 * compiles under MSVC (haven't I broken anything on gcc?)
* half-done support for battles
2008-08-04 15:56:36 +00:00

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;};
};