blob: b31869334a61ae199e93d6fe4607095b203330bc (
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#include "Globals.h"
#include "Promise.h"
cPromise * cPromise::WaitFor(cPromise * a_Promise)
{
return new cCombinedPromise(this, a_Promise);
}
cPromise * cPromise::CancelOn(volatile bool& cancelation)
{
return new cCancelablePromise(this, cancelation);
}
void cPromise::Wait()
{
while(!IsCompleted()){}; //busywait best we can do until waitany
}
cCombinedPromise::cCombinedPromise(cPromise* a_left, cPromise* a_right) :
cPromise(),
m_left(a_left),
m_right(a_right)
{
}
cCombinedPromise::~cCombinedPromise()
{
}
bool cCombinedPromise::IsCompleted()
{
return m_left->IsCompleted() || m_right->IsCompleted();
}
cCancelablePromise::cCancelablePromise(cPromise* a_wrapped, volatile bool& a_cancel) :
cPromise(),
m_cancel(a_cancel),
m_wrapped(a_wrapped)
{
}
cCancelablePromise::~cCancelablePromise ()
{
}
bool cCancelablePromise::IsCompleted()
{
return m_cancel || m_wrapped->IsCompleted();
}
|