nimble/sched: Add way to remove given type of scheduled element

This commit is contained in:
Łukasz Rymanowski
2018-11-03 14:21:21 +01:00
parent 525af73e7d
commit bbfe468774
2 changed files with 34 additions and 1 deletions
@@ -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,
+31
View File
@@ -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.
*