mirror of
https://github.com/flipperdevices/flipperzero-firmware.git
synced 2025-12-12 12:51:22 +04:00
* Abstract primitive type from main logic in FuriEventLoop * Remove message_queue_i.h * Add stream buffer support for event loop * Add semaphore support for event loop * Add temporary unit test workaround * Make the linter happy * Add mutex support for event loop * Implement event subscription and unsubscription while the event loop is running * Implement edge events * Fix leftover logical errors * Add event loop timer example application * Implement flag-based edge trigger and one-shot mode * Add event loop mutex example application * Only notify the event loop if stream buffer is at or above its trigger level * Reformat comments * Add event loop stream buffer example application * Add event loop multiple elements example application * Improve event loop flag names * Remove redundant signal handler as it is already handled by the event loop * Refactor Power service, improve ViewHolder * Use ViewHolder instead of ViewDispatcher in About app * Enable ViewDispatcher queue on construction, deprecate view_dispatcher_enable_queue() * Remove all invocations of view_dispatcher_enable_queue() * Remove app-scened-template * Remove missing library from target.json * Port Accessor app to ViewHolder * Make the linter happy * Add example_view_holder application, update ViewHolder docs * Add example_view_dispatcher application, update ViewDispatcher docs * Replace FuriSemaphore with FuriApiLock, remove workaround delay * Fix logical error * Fix another logical error * Use the sources directive to speed up compilation * Use constant define macro * Improve FuriEventLoop documentation * Improve FuriEventLoop documentation once more * Bump API Version * Gui: remove redundant checks from ViewDispatcher * Gui: remove dead ifs from ViewDispatcher Co-authored-by: Silent <CookiePLMonster@users.noreply.github.com> Co-authored-by: hedger <hedger@users.noreply.github.com> Co-authored-by: あく <alleteam@gmail.com>
67 lines
1.4 KiB
C
67 lines
1.4 KiB
C
/**
|
|
* @file semaphore.h
|
|
* FuriSemaphore
|
|
*/
|
|
#pragma once
|
|
|
|
#include "base.h"
|
|
#include "thread.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef struct FuriSemaphore FuriSemaphore;
|
|
|
|
/** Allocate semaphore
|
|
*
|
|
* @param[in] max_count The maximum count
|
|
* @param[in] initial_count The initial count
|
|
*
|
|
* @return pointer to FuriSemaphore instance
|
|
*/
|
|
FuriSemaphore* furi_semaphore_alloc(uint32_t max_count, uint32_t initial_count);
|
|
|
|
/** Free semaphore
|
|
*
|
|
* @param instance The pointer to FuriSemaphore instance
|
|
*/
|
|
void furi_semaphore_free(FuriSemaphore* instance);
|
|
|
|
/** Acquire semaphore
|
|
*
|
|
* @param instance The pointer to FuriSemaphore instance
|
|
* @param[in] timeout The timeout
|
|
*
|
|
* @return The furi status.
|
|
*/
|
|
FuriStatus furi_semaphore_acquire(FuriSemaphore* instance, uint32_t timeout);
|
|
|
|
/** Release semaphore
|
|
*
|
|
* @param instance The pointer to FuriSemaphore instance
|
|
*
|
|
* @return The furi status.
|
|
*/
|
|
FuriStatus furi_semaphore_release(FuriSemaphore* instance);
|
|
|
|
/** Get semaphore count
|
|
*
|
|
* @param instance The pointer to FuriSemaphore instance
|
|
*
|
|
* @return Semaphore count
|
|
*/
|
|
uint32_t furi_semaphore_get_count(FuriSemaphore* instance);
|
|
|
|
/** Get available space
|
|
*
|
|
* @param instance The pointer to FuriSemaphore instance
|
|
*
|
|
* @return Semaphore available space
|
|
*/
|
|
uint32_t furi_semaphore_get_space(FuriSemaphore* instance);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|