summaryrefslogtreecommitdiff
path: root/source/modules/asura-utils/threading/conditional.h
blob: 3aee392b12dbe54b1668cf39a9b9407f9ed1e767 (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 m_Mutex; 

			Semaphore m_WaitSem;
			Semaphore m_DoneSem; 

			int m_Waiting; 
			int m_Signals;

		};

	}
}

#endif