1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00
vcmi/lib/CondSh.h
mateuszb cc631b1362 * next ubuntux's patch
* normalized line endings (CR+LF)
* translated comments in CMessage.cpp
2009-04-16 11:14:13 +00:00

27 lines
695 B
C++

#ifndef __CONDSH_H__
#define __CONDSH_H__
#include <boost/thread.hpp>
/*
* CondSh.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
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;};
};
#endif // __CONDSH_H__