Lines Matching full:queue
10 * @brief dynamic-size QUEUE object.
37 * struct, which is what got put in the queue. Free it and pass in z_queue_node_peek()
48 /* Data was directly placed in the queue, the first word in z_queue_node_peek()
58 void z_impl_k_queue_init(struct k_queue *queue) in z_impl_k_queue_init() argument
60 sys_sflist_init(&queue->data_q); in z_impl_k_queue_init()
61 queue->lock = (struct k_spinlock) {}; in z_impl_k_queue_init()
62 z_waitq_init(&queue->wait_q); in z_impl_k_queue_init()
64 sys_dlist_init(&queue->poll_events); in z_impl_k_queue_init()
67 SYS_PORT_TRACING_OBJ_INIT(k_queue, queue); in z_impl_k_queue_init()
69 k_object_init(queue); in z_impl_k_queue_init()
73 static inline void z_vrfy_k_queue_init(struct k_queue *queue) in z_vrfy_k_queue_init() argument
75 K_OOPS(K_SYSCALL_OBJ_NEVER_INIT(queue, K_OBJ_QUEUE)); in z_vrfy_k_queue_init()
76 z_impl_k_queue_init(queue); in z_vrfy_k_queue_init()
87 static inline void handle_poll_events(struct k_queue *queue, uint32_t state) in handle_poll_events() argument
90 z_handle_obj_poll_events(&queue->poll_events, state); in handle_poll_events()
92 ARG_UNUSED(queue); in handle_poll_events()
97 void z_impl_k_queue_cancel_wait(struct k_queue *queue) in z_impl_k_queue_cancel_wait() argument
99 SYS_PORT_TRACING_OBJ_FUNC(k_queue, cancel_wait, queue); in z_impl_k_queue_cancel_wait()
101 k_spinlock_key_t key = k_spin_lock(&queue->lock); in z_impl_k_queue_cancel_wait()
104 first_pending_thread = z_unpend_first_thread(&queue->wait_q); in z_impl_k_queue_cancel_wait()
110 handle_poll_events(queue, K_POLL_STATE_CANCELLED); in z_impl_k_queue_cancel_wait()
111 z_reschedule(&queue->lock, key); in z_impl_k_queue_cancel_wait()
115 static inline void z_vrfy_k_queue_cancel_wait(struct k_queue *queue) in z_vrfy_k_queue_cancel_wait() argument
117 K_OOPS(K_SYSCALL_OBJ(queue, K_OBJ_QUEUE)); in z_vrfy_k_queue_cancel_wait()
118 z_impl_k_queue_cancel_wait(queue); in z_vrfy_k_queue_cancel_wait()
123 static int32_t queue_insert(struct k_queue *queue, void *prev, void *data, in queue_insert() argument
127 k_spinlock_key_t key = k_spin_lock(&queue->lock); in queue_insert()
129 SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_queue, queue_insert, queue, alloc); in queue_insert()
132 prev = sys_sflist_peek_tail(&queue->data_q); in queue_insert()
134 first_pending_thread = z_unpend_first_thread(&queue->wait_q); in queue_insert()
137 SYS_PORT_TRACING_OBJ_FUNC_BLOCKING(k_queue, queue_insert, queue, alloc, K_FOREVER); in queue_insert()
140 z_reschedule(&queue->lock, key); in queue_insert()
142 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_queue, queue_insert, queue, alloc, 0); in queue_insert()
153 k_spin_unlock(&queue->lock, key); in queue_insert()
155 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_queue, queue_insert, queue, alloc, in queue_insert()
167 SYS_PORT_TRACING_OBJ_FUNC_BLOCKING(k_queue, queue_insert, queue, alloc, K_FOREVER); in queue_insert()
169 sys_sflist_insert(&queue->data_q, prev, data); in queue_insert()
170 handle_poll_events(queue, K_POLL_STATE_DATA_AVAILABLE); in queue_insert()
171 z_reschedule(&queue->lock, key); in queue_insert()
173 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_queue, queue_insert, queue, alloc, 0); in queue_insert()
178 void k_queue_insert(struct k_queue *queue, void *prev, void *data) in k_queue_insert() argument
180 SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_queue, insert, queue); in k_queue_insert()
182 (void)queue_insert(queue, prev, data, false, false); in k_queue_insert()
184 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_queue, insert, queue); in k_queue_insert()
187 void k_queue_append(struct k_queue *queue, void *data) in k_queue_append() argument
189 SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_queue, append, queue); in k_queue_append()
191 (void)queue_insert(queue, NULL, data, false, true); in k_queue_append()
193 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_queue, append, queue); in k_queue_append()
196 void k_queue_prepend(struct k_queue *queue, void *data) in k_queue_prepend() argument
198 SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_queue, prepend, queue); in k_queue_prepend()
200 (void)queue_insert(queue, NULL, data, false, false); in k_queue_prepend()
202 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_queue, prepend, queue); in k_queue_prepend()
205 int32_t z_impl_k_queue_alloc_append(struct k_queue *queue, void *data) in z_impl_k_queue_alloc_append() argument
207 SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_queue, alloc_append, queue); in z_impl_k_queue_alloc_append()
209 int32_t ret = queue_insert(queue, NULL, data, true, true); in z_impl_k_queue_alloc_append()
211 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_queue, alloc_append, queue, ret); in z_impl_k_queue_alloc_append()
217 static inline int32_t z_vrfy_k_queue_alloc_append(struct k_queue *queue, in z_vrfy_k_queue_alloc_append() argument
220 K_OOPS(K_SYSCALL_OBJ(queue, K_OBJ_QUEUE)); in z_vrfy_k_queue_alloc_append()
221 return z_impl_k_queue_alloc_append(queue, data); in z_vrfy_k_queue_alloc_append()
226 int32_t z_impl_k_queue_alloc_prepend(struct k_queue *queue, void *data) in z_impl_k_queue_alloc_prepend() argument
228 SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_queue, alloc_prepend, queue); in z_impl_k_queue_alloc_prepend()
230 int32_t ret = queue_insert(queue, NULL, data, true, false); in z_impl_k_queue_alloc_prepend()
232 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_queue, alloc_prepend, queue, ret); in z_impl_k_queue_alloc_prepend()
238 static inline int32_t z_vrfy_k_queue_alloc_prepend(struct k_queue *queue, in z_vrfy_k_queue_alloc_prepend() argument
241 K_OOPS(K_SYSCALL_OBJ(queue, K_OBJ_QUEUE)); in z_vrfy_k_queue_alloc_prepend()
242 return z_impl_k_queue_alloc_prepend(queue, data); in z_vrfy_k_queue_alloc_prepend()
247 int k_queue_append_list(struct k_queue *queue, void *head, void *tail) in k_queue_append_list() argument
249 SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_queue, append_list, queue); in k_queue_append_list()
253 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_queue, append_list, queue, -EINVAL); in k_queue_append_list()
258 k_spinlock_key_t key = k_spin_lock(&queue->lock); in k_queue_append_list()
262 thread = z_unpend_first_thread(&queue->wait_q); in k_queue_append_list()
268 thread = z_unpend_first_thread(&queue->wait_q); in k_queue_append_list()
272 sys_sflist_append_list(&queue->data_q, head, tail); in k_queue_append_list()
275 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_queue, append_list, queue, 0); in k_queue_append_list()
277 handle_poll_events(queue, K_POLL_STATE_DATA_AVAILABLE); in k_queue_append_list()
278 z_reschedule(&queue->lock, key); in k_queue_append_list()
282 int k_queue_merge_slist(struct k_queue *queue, sys_slist_t *list) in k_queue_merge_slist() argument
286 SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_queue, merge_slist, queue); in k_queue_merge_slist()
290 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_queue, merge_slist, queue, -EINVAL); in k_queue_merge_slist()
304 ret = k_queue_append_list(queue, list->head, list->tail); in k_queue_merge_slist()
306 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_queue, merge_slist, queue, ret); in k_queue_merge_slist()
312 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_queue, merge_slist, queue, 0); in k_queue_merge_slist()
317 void *z_impl_k_queue_get(struct k_queue *queue, k_timeout_t timeout) in z_impl_k_queue_get() argument
319 k_spinlock_key_t key = k_spin_lock(&queue->lock); in z_impl_k_queue_get()
322 SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_queue, get, queue, timeout); in z_impl_k_queue_get()
324 if (likely(!sys_sflist_is_empty(&queue->data_q))) { in z_impl_k_queue_get()
327 node = sys_sflist_get_not_empty(&queue->data_q); in z_impl_k_queue_get()
329 k_spin_unlock(&queue->lock, key); in z_impl_k_queue_get()
331 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_queue, get, queue, timeout, data); in z_impl_k_queue_get()
336 SYS_PORT_TRACING_OBJ_FUNC_BLOCKING(k_queue, get, queue, timeout); in z_impl_k_queue_get()
339 k_spin_unlock(&queue->lock, key); in z_impl_k_queue_get()
341 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_queue, get, queue, timeout, NULL); in z_impl_k_queue_get()
346 int ret = z_pend_curr(&queue->lock, key, &queue->wait_q, timeout); in z_impl_k_queue_get()
348 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_queue, get, queue, timeout, in z_impl_k_queue_get()
354 bool k_queue_remove(struct k_queue *queue, void *data) in k_queue_remove() argument
356 SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_queue, remove, queue); in k_queue_remove()
358 bool ret = sys_sflist_find_and_remove(&queue->data_q, (sys_sfnode_t *)data); in k_queue_remove()
360 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_queue, remove, queue, ret); in k_queue_remove()
365 bool k_queue_unique_append(struct k_queue *queue, void *data) in k_queue_unique_append() argument
367 SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_queue, unique_append, queue); in k_queue_unique_append()
371 SYS_SFLIST_FOR_EACH_NODE(&queue->data_q, test) { in k_queue_unique_append()
373 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_queue, unique_append, queue, false); in k_queue_unique_append()
379 k_queue_append(queue, data); in k_queue_unique_append()
381 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_queue, unique_append, queue, true); in k_queue_unique_append()
386 void *z_impl_k_queue_peek_head(struct k_queue *queue) in z_impl_k_queue_peek_head() argument
388 void *ret = z_queue_node_peek(sys_sflist_peek_head(&queue->data_q), false); in z_impl_k_queue_peek_head()
390 SYS_PORT_TRACING_OBJ_FUNC(k_queue, peek_head, queue, ret); in z_impl_k_queue_peek_head()
395 void *z_impl_k_queue_peek_tail(struct k_queue *queue) in z_impl_k_queue_peek_tail() argument
397 void *ret = z_queue_node_peek(sys_sflist_peek_tail(&queue->data_q), false); in z_impl_k_queue_peek_tail()
399 SYS_PORT_TRACING_OBJ_FUNC(k_queue, peek_tail, queue, ret); in z_impl_k_queue_peek_tail()
405 static inline void *z_vrfy_k_queue_get(struct k_queue *queue, in z_vrfy_k_queue_get() argument
408 K_OOPS(K_SYSCALL_OBJ(queue, K_OBJ_QUEUE)); in z_vrfy_k_queue_get()
409 return z_impl_k_queue_get(queue, timeout); in z_vrfy_k_queue_get()
413 static inline int z_vrfy_k_queue_is_empty(struct k_queue *queue) in z_vrfy_k_queue_is_empty() argument
415 K_OOPS(K_SYSCALL_OBJ(queue, K_OBJ_QUEUE)); in z_vrfy_k_queue_is_empty()
416 return z_impl_k_queue_is_empty(queue); in z_vrfy_k_queue_is_empty()
420 static inline void *z_vrfy_k_queue_peek_head(struct k_queue *queue) in z_vrfy_k_queue_peek_head() argument
422 K_OOPS(K_SYSCALL_OBJ(queue, K_OBJ_QUEUE)); in z_vrfy_k_queue_peek_head()
423 return z_impl_k_queue_peek_head(queue); in z_vrfy_k_queue_peek_head()
427 static inline void *z_vrfy_k_queue_peek_tail(struct k_queue *queue) in z_vrfy_k_queue_peek_tail() argument
429 K_OOPS(K_SYSCALL_OBJ(queue, K_OBJ_QUEUE)); in z_vrfy_k_queue_peek_tail()
430 return z_impl_k_queue_peek_tail(queue); in z_vrfy_k_queue_peek_tail()