summaryrefslogtreecommitdiff
path: root/source/modules/asura-utils/Threads/Conditional.h
blob: 7a99ea14a4032991e4e5ba6a2814a717ed86643c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef _ASURA_CONDITIONAL_H_
#define _ASURA_CONDITIONAL_H_

#include <asura-utils/Classes.h>

#include "Mutex.h"
#include "Semaphore.h"

namespace_begin(AsuraEngine)
namespace_begin(Threads)

///
/// 
///
class Conditional
{
public:

	Conditional();
	~Conditional();

	void Signal();
	void Broadcast();
	bool Wait(Mutex* mutex, int timeout = ASURA_MUTEX_MAXWAIT);

private:

	Mutex m_Mutex; 

	Semaphore m_WaitSem;
	Semaphore m_DoneSem; 

	int m_Waiting; 
	int m_Signals;

};

namespace_end
namespace_end

#endif