summaryrefslogtreecommitdiffstats
path: root/src/OSSupport/Promise.h
blob: 83d04860bd3b623441eee2a3d620bff9a9ad594f (plain) (blame)
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
#pragma once

class cCombinedPromise;


class cPromise {
	public:
		cPromise() {}
		virtual ~cPromise () {}
		cPromise * WaitFor(cPromise * a_Promise);
		cPromise * CancelOn(volatile bool& cancelationtoken);
		void Wait();
		virtual bool IsCompleted() = 0;
		//TODO:Expose Events for waiting on
};

class cCombinedPromise : public cPromise {
public:
	cCombinedPromise(cPromise*, cPromise*);
	~cCombinedPromise();
	virtual bool IsCompleted();
private:
	cPromise* m_left;
	cPromise* m_right;
};

class cCancelablePromise : public cPromise {
public:
	cCancelablePromise(cPromise*, volatile bool&);
	~cCancelablePromise();
	virtual bool IsCompleted();
private:
	volatile bool& m_cancel;
	cPromise* m_wrapped;
};