| 361 | } |
| 362 | |
| 363 | uint32_t KillTimers(HTimerWorld timer_world, uintptr_t owner) |
| 364 | { |
| 365 | assert(timer_world != 0x0); |
| 366 | |
| 367 | uint32_t size = CopyIndices(timer_world->m_Instances, timer_world->m_ScratchBuffer); |
| 368 | uint32_t cancelled_count = 0; |
| 369 | for (uint32_t i = 0; i < size; ++i) |
| 370 | { |
| 371 | uint16_t index = timer_world->m_ScratchBuffer[i]; |
| 372 | Timer* timer = GetTimerFromIndex(timer_world, index); |
| 373 | |
| 374 | if (!timer) |
| 375 | { |
| 376 | continue; |
| 377 | } |
| 378 | |
| 379 | if (timer->m_Owner != owner) |
| 380 | { |
| 381 | continue; |
| 382 | } |
| 383 | |
| 384 | if (timer->m_IsAlive == 1) |
| 385 | { |
| 386 | timer->m_IsAlive = 0; |
| 387 | ++cancelled_count; |
| 388 | } |
| 389 | |
| 390 | if (timer_world->m_InUpdate == 0) |
| 391 | { |
| 392 | FreeTimer(timer_world, timer); |
| 393 | } |
| 394 | } |
| 395 | |
| 396 | return cancelled_count; |
| 397 | } |
| 398 | |
| 399 | // For testing |
| 400 | uint32_t GetAliveTimers(HTimerWorld timer_world) |