-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFutureObject.h
53 lines (51 loc) · 1.55 KB
/
FutureObject.h
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
#pragma once
#include "Convert.hpp"
#include "KRunnable.h"
class FutureObject :
public NativeObject,public KFuture
{
virtual void BeforeDestruction(void) {
}
public:
tTJSVariant result;
FutureObject() {
putFunc(L"wait", [this]TJSNATIVEARG{
if (n > 0)
*r = wait(p[0]->AsInteger());
else
wait();
return TJS_S_OK;
});
putFunc(L"isCompleted", [this]TJSNATIVEARG{
*r = isCompleted();
return TJS_S_OK;
});
putFunc(L"onComplete", []TJSNATIVEARG{ return TJS_S_OK; });
putFunc(L"onFail", []TJSNATIVEARG{ return TJS_S_OK; });
putProp<tTJSVariant>(L"result", [this](){return result; });
}
virtual void start() {
AddRef();
__super::start();
}
virtual void fail() {
__super::fail();
//TVPAddLog(ttstr((int)GetRefCount()).c_str());
//(new KRunnable([this] {/*TVPPostEvent(this, this, ttstr(L"onComplete"), NULL, NULL, 0,0); */this->FuncCall(0, L"onComplete", 0, NULL, 0, NULL, this); }))->runTask();
//auto par = new tTJSVariant[0];
TVPPostEvent(this, this, ttstr(L"onFail"), NULL, NULL, 0, 0);
//TVPAddLog(ttstr((int)GetRefCount()).c_str());
Release();
//delete[] par;
}
virtual void complete() {
__super::complete();
//TVPAddLog(ttstr((int)GetRefCount()).c_str());
//(new KRunnable([this] {/*TVPPostEvent(this, this, ttstr(L"onComplete"), NULL, NULL, 0,0); */this->FuncCall(0, L"onComplete", 0, NULL, 0, NULL, this); }))->runTask();
//auto par = new tTJSVariant[0];
TVPPostEvent(this,this,ttstr(L"onComplete"),NULL,NULL,1,&result);
//TVPAddLog(ttstr((int)GetRefCount()).c_str());
Release();
//delete[] par;
}
};