mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-26 22:57:00 +02:00
cc631b1362
* normalized line endings (CR+LF) * translated comments in CMessage.cpp
27 lines
695 B
C++
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__
|