summaryrefslogtreecommitdiff
path: root/Source/modules/asura-base/Threads/Conditional.h
blob: ee818cabba252d792ded1915233f0470ea6a409e (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-base/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