mirror of
https://github.com/newdigate/teensy-x86-stubs.git
synced 2026-07-04 14:46:42 +00:00
9835f5ee2b
The previous implementation used a single static SIGALRM handler and one ITIMER_REAL, so a second IntervalTimer silently clobbered the first despite the API documenting up to 4 simultaneous timers. Reimplement with one std::thread per active timer, each invoking its callback at the requested period via sleep_until. A static slot counter caps concurrent timers at 4 (matching the Teensy 4.x PIT channels); begin() returns false once all 4 are in use, and end() frees the slot. update() retimes the next interval, and a self-end() from within a callback detaches rather than joining to avoid deadlock. Because the library now uses std::thread, src/CMakeLists.txt links Threads::Threads PUBLIC so consumers (e.g. test/blink) link pthread transitively. Adds a test/bugs regression test covering four concurrent timers, the max-4 limit, and slot reuse after end(). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FAsvzgsaayj2nbZnnQGAav