mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-11-28 02:45:45 +03:00
e9e76e144c
* RPC: Update protobuf sources * RPC: Implement storage_stat_request * RPC: Test storage_stat_request * FuriRecord: fix use after free in destroy method. * Furi: refactor PubSub and it's usage. Fix allocation in RPC. * FuriCore: fix memory leak in pubsub * FuriCore: update unsubscribe method signature in pubsub, make subscription structure lighter. * FuriCore: remove dead code Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
65 lines
1.6 KiB
C
65 lines
1.6 KiB
C
#pragma once
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/** FuriPubSub Callback type */
|
|
typedef void (*FuriPubSubCallback)(const void* message, void* context);
|
|
|
|
/** FuriPubSub type */
|
|
typedef struct FuriPubSub FuriPubSub;
|
|
|
|
/** FuriPubSubSubscription type */
|
|
typedef struct FuriPubSubSubscription FuriPubSubSubscription;
|
|
|
|
/** Allocate FuriPubSub
|
|
*
|
|
* Reentrable, Not threadsafe, one owner
|
|
*
|
|
* @return pointer to FuriPubSub instance
|
|
*/
|
|
FuriPubSub* furi_pubsub_alloc();
|
|
|
|
/** Free FuriPubSub
|
|
*
|
|
* @param pubsub FuriPubSub instance
|
|
*/
|
|
void furi_pubsub_free(FuriPubSub* pubsub);
|
|
|
|
/** Subscribe to FuriPubSub
|
|
*
|
|
* Threadsafe, Reentrable
|
|
*
|
|
* @param pubsub pointer to FuriPubSub instance
|
|
* @param[in] callback The callback
|
|
* @param callback_context The callback context
|
|
*
|
|
* @return pointer to FuriPubSubSubscription instance
|
|
*/
|
|
FuriPubSubSubscription*
|
|
furi_pubsub_subscribe(FuriPubSub* pubsub, FuriPubSubCallback callback, void* callback_context);
|
|
|
|
/** Unsubscribe from FuriPubSub
|
|
*
|
|
* No use of `pubsub_subscription` allowed after call of this method
|
|
* Threadsafe, Reentrable.
|
|
*
|
|
* @param pubsub pointer to FuriPubSub instance
|
|
* @param pubsub_subscription pointer to FuriPubSubSubscription instance
|
|
*/
|
|
void furi_pubsub_unsubscribe(FuriPubSub* pubsub, FuriPubSubSubscription* pubsub_subscription);
|
|
|
|
/** Publish message to FuriPubSub
|
|
*
|
|
* Threadsafe, Reentrable.
|
|
*
|
|
* @param pubsub pointer to FuriPubSub instance
|
|
* @param message message pointer to publish
|
|
*/
|
|
void furi_pubsub_publish(FuriPubSub* pubsub, void* message);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|