summaryrefslogtreecommitdiff
path: root/source/modules/asura-utils/threading/conditional.h
blob: 2f9633e5c951d10b177a59f8ef9f939265cc4db2 (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 "mutex.h"
#include "semaphore.h"

namespace AsuraEngine
{
	namespace Threading
	{

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

			Conditional();
			~Conditional();

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

		private:

			Mutex mMutex; 

			Semaphore mWaitSem;
			Semaphore mDoneSem; 

			int mWaiting; 
			int mSignals;

		};

	}
}

#endif