| 426 | } |
| 427 | |
| 428 | void ParlioEngine::cleanup() FL_NOEXCEPT { |
| 429 | #ifdef FL_DEBUG |
| 430 | // Clean up debug task only - singleton remains alive |
| 431 | // This is called before DLL unload to properly join threads |
| 432 | if (mDebugTask.is_valid()) { |
| 433 | // Signal task to exit by setting flags to false |
| 434 | if (mIsrContext) { |
| 435 | mIsrContext->mTransmitting.store(false, fl::memory_order_release); |
| 436 | mIsrContext->mStreamComplete.store(false, fl::memory_order_release); |
| 437 | } |
| 438 | // Give task time to self-delete (task sleeps for 500ms) |
| 439 | if (mPeripheral) { |
| 440 | mPeripheral->delay(600); |
| 441 | } |
| 442 | // Cancel the task to release resources |
| 443 | mDebugTask.cancel(); |
| 444 | } |
| 445 | #endif |
| 446 | } |
| 447 | |
| 448 | #ifdef FL_DEBUG |
| 449 | //============================================================================= |