Lines Matching full:event

11  * @brief Kernel asynchronous event polling interface.
29 /* Single subsystem lock. Locking per-event would be better on highly
40 static int signal_poller(struct k_poll_event *event, uint32_t state);
41 static int signal_triggered_work(struct k_poll_event *event, uint32_t status);
43 void k_poll_event_init(struct k_poll_event *event, uint32_t type, in k_poll_event_init() argument
51 event->poller = NULL; in k_poll_event_init()
52 /* event->tag is left uninitialized: the user will set it if needed */ in k_poll_event_init()
53 event->type = type; in k_poll_event_init()
54 event->state = K_POLL_STATE_NOT_READY; in k_poll_event_init()
55 event->mode = mode; in k_poll_event_init()
56 event->unused = 0U; in k_poll_event_init()
57 event->obj = obj; in k_poll_event_init()
59 SYS_PORT_TRACING_FUNC(k_poll_api, event_init, event); in k_poll_event_init()
63 static inline bool is_condition_met(struct k_poll_event *event, uint32_t *state) in is_condition_met() argument
65 switch (event->type) { in is_condition_met()
67 if (k_sem_count_get(event->sem) > 0U) { in is_condition_met()
73 if (!k_queue_is_empty(event->queue)) { in is_condition_met()
79 if (event->signal->signaled != 0U) { in is_condition_met()
85 if (event->msgq->used_msgs > 0) { in is_condition_met()
92 if (k_pipe_read_avail(event->pipe)) { in is_condition_met()
100 __ASSERT(false, "invalid event type (0x%x)\n", event->type); in is_condition_met()
112 static inline void add_event(sys_dlist_t *events, struct k_poll_event *event, in add_event() argument
121 sys_dlist_append(events, &event->_node); in add_event()
128 sys_dlist_insert(&pending->_node, &event->_node); in add_event()
133 sys_dlist_append(events, &event->_node); in add_event()
137 static inline void register_event(struct k_poll_event *event, in register_event() argument
140 switch (event->type) { in register_event()
142 __ASSERT(event->sem != NULL, "invalid semaphore\n"); in register_event()
143 add_event(&event->sem->poll_events, event, poller); in register_event()
146 __ASSERT(event->queue != NULL, "invalid queue\n"); in register_event()
147 add_event(&event->queue->poll_events, event, poller); in register_event()
150 __ASSERT(event->signal != NULL, "invalid poll signal\n"); in register_event()
151 add_event(&event->signal->poll_events, event, poller); in register_event()
154 __ASSERT(event->msgq != NULL, "invalid message queue\n"); in register_event()
155 add_event(&event->msgq->poll_events, event, poller); in register_event()
159 __ASSERT(event->pipe != NULL, "invalid pipe\n"); in register_event()
160 add_event(&event->pipe->poll_events, event, poller); in register_event()
167 __ASSERT(false, "invalid event type\n"); in register_event()
171 event->poller = poller; in register_event()
175 static inline void clear_event_registration(struct k_poll_event *event) in clear_event_registration() argument
179 event->poller = NULL; in clear_event_registration()
181 switch (event->type) { in clear_event_registration()
183 __ASSERT(event->sem != NULL, "invalid semaphore\n"); in clear_event_registration()
187 __ASSERT(event->queue != NULL, "invalid queue\n"); in clear_event_registration()
191 __ASSERT(event->signal != NULL, "invalid poll signal\n"); in clear_event_registration()
195 __ASSERT(event->msgq != NULL, "invalid message queue\n"); in clear_event_registration()
200 __ASSERT(event->pipe != NULL, "invalid pipe\n"); in clear_event_registration()
208 __ASSERT(false, "invalid event type\n"); in clear_event_registration()
211 if (remove_event && sys_dnode_is_linked(&event->_node)) { in clear_event_registration()
212 sys_dlist_remove(&event->_node); in clear_event_registration()
228 static inline void set_event_ready(struct k_poll_event *event, uint32_t state) in set_event_ready() argument
230 event->poller = NULL; in set_event_ready()
231 event->state |= state; in set_event_ready()
253 /* Event is not one of those identified in is_condition_met() in register_events()
265 static int signal_poller(struct k_poll_event *event, uint32_t state) in signal_poller() argument
267 struct k_thread *thread = poller_thread(event->poller); in signal_poller()
310 * If we're not polling anymore, it means that at least one event in z_impl_k_poll()
338 * Clear all event registrations. If events happen while we're in this in z_impl_k_poll()
344 * return code first, which invalidates the whole list of event states. in z_impl_k_poll()
441 static int signal_poll_event(struct k_poll_event *event, uint32_t state) in signal_poll_event() argument
443 struct z_poller *poller = event->poller; in signal_poll_event()
448 retcode = signal_poller(event, state); in signal_poll_event()
450 retcode = signal_triggered_work(event, state); in signal_poll_event()
463 set_event_ready(event, state); in signal_poll_event()
577 * already cleared event registrations. in triggered_work_handler()
606 static int signal_triggered_work(struct k_poll_event *event, uint32_t status) in signal_triggered_work() argument
608 struct z_poller *poller = event->poller; in signal_triggered_work()
626 /* Check if the work waits for event. */ in triggered_work_cancel()
632 * Prevent work execution if event arrives while we will be in triggered_work_cancel()
728 * No event is ready and all are watched. in k_work_poll_submit_to_queue()
740 /* From now, any event will result in submitted work. */ in k_work_poll_submit_to_queue()
750 * The K_NO_WAIT timeout was specified or at least one event in k_work_poll_submit_to_queue()
757 * If poller is still polling, no watched event occurred. This means in k_work_poll_submit_to_queue()