MCPcopy Create free account
hub / github.com/axmolengine/axmol / loop

Method loop

core/base/SimpleTimer.cpp:45–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43uintptr_t TimerObject::s_timerId = 0;
44
45TIMER_ID loop(unsigned int n, float interval, vcallback_t callback, bool bNative)
46{
47 if (n > 0 && interval >= 0)
48 {
49 yasio::ref_ptr<TimerObject> timerObj(new TimerObject(std::move(callback)));
50
51 auto timerId = reinterpret_cast<TIMER_ID>(++TimerObject::s_timerId);
52
53 std::string key = fmt::format("STMR#{}", fmt::ptr(timerId));
54
55 Director::getInstance()->getScheduler()->schedule(
56 [timerObj](float /*dt*/) { // lambda expression hold the reference of timerObj automatically.
57 timerObj->callback_();
58 },
59 STIMER_TARGET(bNative), interval, n - 1, 0, false, key);
60
61 return timerId;
62 }
63 return nullptr;
64}
65
66TIMER_ID delay(float delay, vcallback_t callback, bool bNative)
67{

Callers

nothing calls this directly

Calls 4

getInstanceFunction · 0.85
formatFunction · 0.70
ptrFunction · 0.50
scheduleMethod · 0.45

Tested by

no test coverage detected