MCPcopy Create free account
hub / github.com/FastLED/FastLED / add_handler

Method add_handler

src/platforms/stub/isr_stub.hpp:112–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110 }
111
112 void add_handler(stub_isr_handle_data* handler) FL_NOEXCEPT {
113 fl::unique_lock<fl::mutex> lock(mMutex) FL_NOEXCEPT;
114
115 // Assign unique ID
116 handler->mHandleId = mNextHandleId++;
117
118 // Calculate initial tick time
119 auto now = get_time_us();
120 u64 period_us = handler->mFrequencyHz > 0 ? (1000000ULL / handler->mFrequencyHz) : 0;
121 handler->mNextTickUs = now + period_us;
122
123 mHandlers.push_back(handler);
124
125 // Start timer thread if not already running
126 if (!mTimerThread) {
127 mShouldStop = false;
128 mTimerThread = fl::make_unique<fl::thread>(&TimerThreadManager::timer_thread_func, this);
129 } else {
130 // Wake up the timer thread to process the new handler
131 mCondVar.notify_one();
132 }
133 }
134
135 void reschedule_handler(stub_isr_handle_data* handler) FL_NOEXCEPT {
136 fl::unique_lock<fl::mutex> lock(mMutex) FL_NOEXCEPT;

Callers 1

Calls 2

push_backMethod · 0.45
notify_oneMethod · 0.45

Tested by

no test coverage detected