mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-21 21:41:13 +00:00
btstack_run_loop: add list of callbacks and provide btstack_run_loop_base_execute_callbacks
This commit is contained in:
parent
9fb44c6d99
commit
7eaf37e0f9
@ -60,12 +60,14 @@ extern const btstack_run_loop_t btstack_run_loop_embedded;
|
||||
*/
|
||||
|
||||
// private data (access only by run loop implementations)
|
||||
btstack_linked_list_t btstack_run_loop_base_timers;
|
||||
btstack_linked_list_t btstack_run_loop_base_data_sources;
|
||||
btstack_linked_list_t btstack_run_loop_base_timers;
|
||||
btstack_linked_list_t btstack_run_loop_base_data_sources;
|
||||
btstack_linked_list_t btstack_run_loop_base_callbacks;
|
||||
|
||||
void btstack_run_loop_base_init(void){
|
||||
btstack_run_loop_base_timers = NULL;
|
||||
btstack_run_loop_base_data_sources = NULL;
|
||||
btstack_run_loop_base_callbacks = NULL;
|
||||
}
|
||||
|
||||
void btstack_run_loop_base_add_data_source(btstack_data_source_t * data_source){
|
||||
@ -149,6 +151,22 @@ void btstack_run_loop_base_poll_data_sources(void){
|
||||
}
|
||||
}
|
||||
|
||||
void btstack_run_loop_base_add_callback(btstack_context_callback_registration_t * callback_registration){
|
||||
btstack_linked_list_add_tail(&btstack_run_loop_base_callbacks, (btstack_linked_item_t *) callback_registration);
|
||||
}
|
||||
|
||||
|
||||
void btstack_run_loop_base_execute_callbacks(void){
|
||||
while (1){
|
||||
btstack_context_callback_registration_t * callback_registration = (btstack_context_callback_registration_t *) btstack_linked_list_pop(&btstack_run_loop_base_callbacks);
|
||||
if (callback_registration == NULL){
|
||||
break;
|
||||
}
|
||||
(*callback_registration->callback)(callback_registration->context);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* BTstack Run Loop Implementation, mainly dispatches to port-specific implementation
|
||||
*/
|
||||
|
@ -124,6 +124,7 @@ typedef struct btstack_run_loop {
|
||||
// private data (access only by run loop implementations)
|
||||
extern btstack_linked_list_t btstack_run_loop_base_timers;
|
||||
extern btstack_linked_list_t btstack_run_loop_base_data_sources;
|
||||
extern btstack_linked_list_t btstack_run_loop_base_callbacks;
|
||||
|
||||
/**
|
||||
* @brief Init
|
||||
@ -192,6 +193,16 @@ void btstack_run_loop_base_disable_data_source_callbacks(btstack_data_source_t *
|
||||
*/
|
||||
void btstack_run_loop_base_poll_data_sources(void);
|
||||
|
||||
/**
|
||||
* @bried Add Callbacks to list of callbacks to execute with btstack_run_loop_base_execute_callbacks
|
||||
*/
|
||||
void btstack_run_loop_base_add_callback(btstack_context_callback_registration_t * callback_registration);
|
||||
|
||||
/**
|
||||
* @bried Procss Callbacks: remove all callback-registrations and call the registered function with its context
|
||||
*/
|
||||
void btstack_run_loop_base_execute_callbacks(void);
|
||||
|
||||
|
||||
/* API_START */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user