| 64 | } |
| 65 | |
| 66 | TIMER_ID delay(float delay, vcallback_t callback, bool bNative) |
| 67 | { |
| 68 | if (delay > 0) |
| 69 | { |
| 70 | yasio::ref_ptr<TimerObject> timerObj(new TimerObject(std::move(callback))); |
| 71 | auto timerId = reinterpret_cast<TIMER_ID>(++TimerObject::s_timerId); |
| 72 | |
| 73 | std::string key = fmt::format("STMR#{}", fmt::ptr(timerId)); |
| 74 | Director::getInstance()->getScheduler()->schedule( |
| 75 | [timerObj](float /*dt*/) { // lambda expression hold the reference of timerObj automatically. |
| 76 | timerObj->callback_(); |
| 77 | }, |
| 78 | STIMER_TARGET(bNative), 0, 0, delay, false, key); |
| 79 | |
| 80 | return timerId; |
| 81 | } |
| 82 | return nullptr; |
| 83 | } |
| 84 | |
| 85 | void kill(TIMER_ID timerId, bool bNative) |
| 86 | { |
nothing calls this directly
no test coverage detected