MCPcopy Create free account
hub / github.com/NativeScript/android / Init

Method Init

test-app/runtime/src/main/cpp/Timers.cpp:53–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51
52
53void Timers::Init(v8::Isolate *isolate, v8::Local<v8::ObjectTemplate> &globalObjectTemplate) {
54 isolate_ = isolate;
55 // TODO: remove the __ns__ prefix once this is validated
56 SetMethod(isolate, globalObjectTemplate, "__ns__setTimeout", SetTimeoutCallback, External::New(isolate, this));
57 SetMethod(isolate, globalObjectTemplate, "__ns__setInterval", SetIntervalCallback, External::New(isolate, this));
58 SetMethod(isolate, globalObjectTemplate, "__ns__clearTimeout", ClearTimer, External::New(isolate, this));
59 SetMethod(isolate, globalObjectTemplate, "__ns__clearInterval", ClearTimer, External::New(isolate, this));
60 auto res = pipe(fd_);
61 assert(res != -1);
62 res = fcntl(fd_[1], F_SETFL, O_NONBLOCK);
63 assert(res != -1);
64 // TODO: check success of fd
65 looper_ = ALooper_prepare(0);
66 ALooper_acquire(looper_);
67 ALooper_addFd(looper_, fd_[0], ALOOPER_POLL_CALLBACK, ALOOPER_EVENT_INPUT,
68 PumpTimerLoopCallback, this);
69 ALooper_wake(looper_);
70 watcher_ = std::thread(&Timers::threadLoop, this);
71 stopped = false;
72}
73
74void Timers::addTask(std::shared_ptr<TimerTask> task) {
75 if (task->queued_) {

Callers 1

InitStaticMethod · 0.45

Calls 2

SetMethodFunction · 0.85
NewFunction · 0.85

Tested by

no test coverage detected