mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 04:34:43 +04:00
[FL-3846] Event Loop Timers (#3721)
* Implement POC event loop tmers (not all edge cases are handled) * Use a separate ready list to allow for (re)starting and stopping of timers from callback * Improve the test application * Improve timer API and test application * Improve timeout calculation logic * Improve timer API, update documentation * Fix API usage error * Update doxygen comments * Revert the old (correct) check * Improve function naming * Check whether a timer was on the expired list before processing it * Implement tick callback * Add critical sections to improve timer consistency * Simplify event loop timer API * Remove redundant search * Refactor timer logic, use message queue * Simplify FuriEventLoopTimer API * Improve event loop timer logic * Update the f18 target * Remove superfluous clears * Correct f18 api symbols * Fix doxygen comments * Update .pvsconfig * Use a double push list instead of deque * Update .pvsconfig * Add pending callback functionality * Restore unprocessed flags when applicable * Refactor Dolphin app to use FuriEventLoop * Improve naming * Update naming some more * Fix a typo Co-authored-by: Silent <CookiePLMonster@users.noreply.github.com> * Fix wait time in example * Bump API version * Debug: multiple of 25 timings in event loop blink test * Separate FuriEventLoopTimer to its own set of files * Improve start time calculation for periodic timers * Do not use dynamic allocations for timer requests * Split the tick functionality in separate files, rearrange code * Improve timer queue handling * Properly reset GPIO pins in the test app * Properly initialise GPIO pins in the test app too * Furi: variable naming in event loop * Furi: fix spelling in event loop Co-authored-by: あく <alleteam@gmail.com> Co-authored-by: Silent <CookiePLMonster@users.noreply.github.com>
This commit is contained in:
@@ -34,7 +34,7 @@ typedef struct FuriEventLoop FuriEventLoop;
|
||||
* Couple things to keep in mind:
|
||||
* - You can have 1 event_loop per 1 thread
|
||||
* - You can not use event_loop instance in the other thread
|
||||
* - Do not use blocking api to query object delegated to Event Loop
|
||||
* - Do not use blocking API to query object delegated to Event Loop
|
||||
*
|
||||
* @return The Event Loop instance
|
||||
*/
|
||||
@@ -72,8 +72,10 @@ typedef void (*FuriEventLoopTickCallback)(void* context);
|
||||
|
||||
/** Set Event Loop tick callback
|
||||
*
|
||||
* Tick callback called after specified inactivity time. It's not periodic. If
|
||||
* Event Loop is busy then ticks will be skipped.
|
||||
* Tick callback is called periodically after specified inactivity time.
|
||||
* It acts like a low-priority timer: it will only fire if there is time
|
||||
* left after processing the synchronization primitives and the regular timers.
|
||||
* Therefore, it is not monotonic: ticks will be skipped if the event loop is busy.
|
||||
*
|
||||
* @param instance The Event Loop instance
|
||||
* @param[in] interval The tick interval
|
||||
@@ -86,6 +88,32 @@ void furi_event_loop_tick_set(
|
||||
FuriEventLoopTickCallback callback,
|
||||
void* context);
|
||||
|
||||
/*
|
||||
* Deferred function call API
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Timer callback type for functions to be called in a deferred manner.
|
||||
*
|
||||
* @param[in,out] context pointer to a user-specific object that was provided during
|
||||
* furi_event_loop_pend_callback() call
|
||||
*/
|
||||
typedef void (*FuriEventLoopPendingCallback)(void* context);
|
||||
|
||||
/**
|
||||
* @brief Call a function when all preceding timer commands are processed
|
||||
*
|
||||
* This function may be useful to call another function when the event loop has been started.
|
||||
*
|
||||
* @param[in,out] instance pointer to the current FuriEventLoop instance
|
||||
* @param[in] callback pointer to the callback to be executed when previous commands have been processed
|
||||
* @param[in,out] context pointer to a user-specific object (will be passed to the callback)
|
||||
*/
|
||||
void furi_event_loop_pend_callback(
|
||||
FuriEventLoop* instance,
|
||||
FuriEventLoopPendingCallback callback,
|
||||
void* context);
|
||||
|
||||
/*
|
||||
* Message queue related APIs
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user