Do not use a timer callback

This commit is contained in:
Georgii Surkov 2024-02-09 16:31:45 +03:00
parent 4c2e997997
commit 73deff8863
No known key found for this signature in database
GPG key ID: 44A24455F6ADB5E7
2 changed files with 6 additions and 17 deletions

View file

@ -57,7 +57,7 @@ static void expansion_detect_callback(void* context) {
ExpansionMessage message = {
.type = ExpansionMessageTypeModuleConnected,
.api_lock = NULL, // Not locking the API here
.api_lock = NULL, // Not locking the API here to avoid a deadlock
};
// Not waiting for available queue space, discarding message if there is none
@ -71,7 +71,7 @@ static void expansion_worker_callback(void* context) {
ExpansionMessage message = {
.type = ExpansionMessageTypeModuleDisconnected,
.api_lock = NULL, // Not locking the API here
.api_lock = NULL, // Not locking the API here to avoid a deadlock
};
const FuriStatus status = furi_message_queue_put(instance->queue, &message, FuriWaitForever);

View file

@ -317,18 +317,6 @@ static inline void expansion_worker_state_machine(ExpansionWorker* instance) {
}
}
static void expansion_worker_pending_callback(void* context, uint32_t arg) {
furi_assert(context);
UNUSED(arg);
ExpansionWorker* instance = context;
furi_thread_join(instance->thread);
if(instance->callback != NULL) {
instance->callback(instance->cb_context);
}
}
static int32_t expansion_worker(void* context) {
furi_assert(context);
ExpansionWorker* instance = context;
@ -361,9 +349,9 @@ static int32_t expansion_worker(void* context) {
furi_hal_serial_control_release(instance->serial_handle);
furi_hal_power_insomnia_exit();
// Do not invoke pending callback on user-requested exit
if(instance->exit_reason != ExpansionWorkerExitReasonUser) {
furi_timer_pending_callback(expansion_worker_pending_callback, instance, 0);
// Do not invoke worker callback on user-requested exit
if((instance->exit_reason != ExpansionWorkerExitReasonUser) && (instance->callback != NULL)) {
instance->callback(instance->cb_context);
}
return 0;
@ -385,6 +373,7 @@ ExpansionWorker* expansion_worker_alloc(FuriHalSerialId serial_id) {
void expansion_worker_free(ExpansionWorker* instance) {
furi_stream_buffer_free(instance->rx_buf);
furi_thread_join(instance->thread);
furi_thread_free(instance->thread);
free(instance);
}