File tree Expand file tree Collapse file tree 2 files changed +16
-9
lines changed Expand file tree Collapse file tree 2 files changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -273,8 +273,11 @@ void am_ao_init_subscribe_list(struct am_ao_subscribe_list *sub, int nsub);
273273/**
274274 * Run all active objects.
275275 *
276- * @retval true processed at least one event
277- * @retval false processed no events
276+ * Non blocking.
277+ * Return after dispatching zero or one event.
278+ *
279+ * @retval true dispatched one event
280+ * @retval false dispatched no events
278281 */
279282bool am_ao_run_all (void );
280283
Original file line number Diff line number Diff line change @@ -40,11 +40,14 @@ static struct am_bit_u64 am_ready_aos_ = {0};
4040
4141bool am_ao_run_all (void ) {
4242 struct am_ao_state * me = & am_ao_state_ ;
43- me -> crit_enter ();
44-
45- while (!am_bit_u64_is_empty (& am_ready_aos_ )) {
43+ bool dispatched = false;
44+ do {
45+ me -> crit_enter ();
46+ if (am_bit_u64_is_empty (& am_ready_aos_ )) {
47+ me -> crit_exit ();
48+ break ;
49+ }
4650 int msb = am_bit_u64_msb (& am_ready_aos_ );
47-
4851 me -> crit_exit ();
4952
5053 struct am_ao * ao = me -> ao [msb ];
@@ -66,9 +69,10 @@ bool am_ao_run_all(void) {
6669 AM_ATOMIC_STORE_N (& ao -> last_event , AM_EVT_INVALID );
6770 am_event_free (& e );
6871
69- return true;
70- }
71- return false;
72+ dispatched = true;
73+ } while (!dispatched );
74+
75+ return dispatched ;
7276}
7377
7478void am_ao_start (
You can’t perform that action at this time.
0 commit comments