mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-11-07 04:52:47 +00:00
nimble/sched: Add way to remove given type of scheduled element
This commit is contained in:
@@ -82,7 +82,7 @@ extern uint8_t g_ble_ll_sched_offset_ticks;
|
||||
/* Callback function */
|
||||
struct ble_ll_sched_item;
|
||||
typedef int (*sched_cb_func)(struct ble_ll_sched_item *sch);
|
||||
|
||||
typedef void (*sched_remove_cb_func)(struct ble_ll_sched_item *sch);
|
||||
/*
|
||||
* Strict connection scheduling (for the master) is different than how
|
||||
* connections are normally scheduled. With strict connection scheduling we
|
||||
@@ -143,6 +143,8 @@ int ble_ll_sched_init(void);
|
||||
/* Remove item(s) from schedule */
|
||||
void ble_ll_sched_rmv_elem(struct ble_ll_sched_item *sch);
|
||||
|
||||
void ble_ll_sched_rmv_elem_type(uint8_t type, sched_remove_cb_func remove_cb);
|
||||
|
||||
/* Schedule a new master connection */
|
||||
struct ble_ll_conn_sm;
|
||||
int ble_ll_sched_master_new(struct ble_ll_conn_sm *connsm,
|
||||
|
||||
@@ -1098,6 +1098,37 @@ ble_ll_sched_rmv_elem(struct ble_ll_sched_item *sch)
|
||||
OS_EXIT_CRITICAL(sr);
|
||||
}
|
||||
|
||||
void
|
||||
ble_ll_sched_rmv_elem_type(uint8_t type, sched_remove_cb_func remove_cb)
|
||||
{
|
||||
os_sr_t sr;
|
||||
struct ble_ll_sched_item *entry;
|
||||
struct ble_ll_sched_item *first;
|
||||
|
||||
OS_ENTER_CRITICAL(sr);
|
||||
first = TAILQ_FIRST(&g_ble_ll_sched_q);
|
||||
|
||||
TAILQ_FOREACH(entry, &g_ble_ll_sched_q, link) {
|
||||
if (entry->sched_type == type) {
|
||||
if (first == entry) {
|
||||
os_cputime_timer_stop(&g_ble_ll_sched_timer);
|
||||
first = NULL;
|
||||
}
|
||||
|
||||
TAILQ_REMOVE(&g_ble_ll_sched_q, entry, link);
|
||||
remove_cb(entry);
|
||||
entry->enqueued = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!first) {
|
||||
first = TAILQ_FIRST(&g_ble_ll_sched_q);
|
||||
os_cputime_timer_start(&g_ble_ll_sched_timer, first->start_time);
|
||||
}
|
||||
|
||||
OS_EXIT_CRITICAL(sr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a schedule item by calling the schedule callback function.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user