Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
timeout_q.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 Wind River Systems, Inc.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_KERNEL_INCLUDE_TIMEOUT_Q_H_
8#define ZEPHYR_KERNEL_INCLUDE_TIMEOUT_Q_H_
9
15#include <kernel.h>
16
17#include <stdbool.h>
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23#ifdef CONFIG_SYS_CLOCK_EXISTS
24
25static inline void z_init_timeout(struct _timeout *to)
26{
27 sys_dnode_init(&to->node);
28}
29
30void z_add_timeout(struct _timeout *to, _timeout_func_t fn,
32
33int z_abort_timeout(struct _timeout *to);
34
35static inline bool z_is_inactive_timeout(const struct _timeout *to)
36{
37 return !sys_dnode_is_linked(&to->node);
38}
39
40static inline void z_init_thread_timeout(struct _thread_base *thread_base)
41{
42 z_init_timeout(&thread_base->timeout);
43}
44
45extern void z_thread_timeout(struct _timeout *timeout);
46
47static inline void z_add_thread_timeout(struct k_thread *thread, k_timeout_t ticks)
48{
49 z_add_timeout(&thread->base.timeout, z_thread_timeout, ticks);
50}
51
52static inline int z_abort_thread_timeout(struct k_thread *thread)
53{
54 return z_abort_timeout(&thread->base.timeout);
55}
56
57int32_t z_get_next_timeout_expiry(void);
58
59void z_set_timeout_expiry(int32_t ticks, bool is_idle);
60
61k_ticks_t z_timeout_remaining(const struct _timeout *timeout);
62
63#else
64
65/* Stubs when !CONFIG_SYS_CLOCK_EXISTS */
66#define z_init_thread_timeout(thread_base) do {} while (false)
67#define z_abort_thread_timeout(to) (0)
68#define z_is_inactive_timeout(to) 0
69#define z_get_next_timeout_expiry() ((int32_t) K_TICKS_FOREVER)
70#define z_set_timeout_expiry(ticks, is_idle) do {} while (false)
71
72static inline void z_add_thread_timeout(struct k_thread *thread, k_timeout_t ticks)
73{
74 ARG_UNUSED(thread);
75 ARG_UNUSED(ticks);
76}
77
78#endif
79
80#ifdef __cplusplus
81}
82#endif
83
84#endif /* ZEPHYR_KERNEL_INCLUDE_TIMEOUT_Q_H_ */
static struct k_thread thread[2]
Definition: atomic.c:22
ZTEST_BMEM int timeout
Definition: main.c:31
uint32_t k_ticks_t
Tick precision used in timeout APIs.
Definition: sys_clock.h:48
static bool sys_dnode_is_linked(const sys_dnode_t *node)
check if a node is a member of any list
Definition: dlist.h:229
static void sys_dnode_init(sys_dnode_t *node)
initialize node to its state when not in a list
Definition: dlist.h:215
__INT32_TYPE__ int32_t
Definition: stdint.h:44
Definition: thread.h:201
struct _thread_base base
Definition: thread.h:203
Kernel timeout type.
Definition: sys_clock.h:65