picox  0.1
xvtimer.h
[詳解]
1 
15 /*
16  * License: MIT license
17  * Copyright (c) <2016> <MaskedW [maskedw00@gmail.com]>
18  *
19  * Permission is hereby granted, free of charge, to any person
20  * obtaining a copy of self software and associated documentation
21  * files (the "Software"), to deal in the Software without
22  * restriction, including without limitation the rights to use, copy,
23  * modify, merge, publish, distribute, sublicense, and/or sell copies
24  * of the Software, and to permit persons to whom the Software is
25  * furnished to do so, subject to the following conditions:
26  *
27  * The above copyright notice and self permission notice shall be
28  * included in all copies or substantial portions of the Software.
29  *
30  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
33  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
34  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
35  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
36  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37  * SOFTWARE.
38  */
39 
40 
41 #ifndef picox_multitask_xvtimer_h_
42 #define picox_multitask_xvtimer_h_
43 
44 
45 #include <picox/core/xcore.h>
47 
48 
62 #ifdef __cplusplus
63 extern "C" {
64 #endif /* __cplusplus */
65 
66 
67 struct XVTimer;
68 struct XVTimerRequest;
69 typedef struct XVTimer XVTimer;
70 typedef struct XVTimerRequest XVTimerRequest;
71 
72 
74 typedef void (*XVTimerCallBack)(void* arg);
75 
76 
82 {
85  void* arg;
86  XTicks delay;
87  XTicks interval;
88  XDeleter deleter;
89 
91  XIntrusiveNode m_node;
92  XTicks m_count;
93  XVTimer* m_holder;
94  unsigned m_has_marked_for_deletion : 1;
95  unsigned m_pending : 1;
96  unsigned m_is_delayed : 1;
97  unsigned m_once : 1;
98 };
99 
100 
103 struct XVTimer
104 {
106  XIntrusiveList m_requests;
107  XIntrusiveList m_pending_requests;
108  XTicks m_tick_count;
109  bool m_in_scheduling;
110 };
111 
112 
115 void xvtimer_init(XVTimer* self);
116 
117 
120 void xvtimer_init_request(XVTimerRequest* request);
121 
122 
125 void xvtimer_deinit(XVTimer* self);
126 
127 
138 void xvtimer_add_request(XVTimer* self,
139  XVTimerRequest* request,
141  void* arg,
142  XTicks delay,
143  XTicks interval,
144  bool once,
145  XDeleter deleter);
146 
147 
153 void xvtimer_remove_requst(XVTimer* self, XVTimerRequest* request);
154 
155 
161 void xvtimer_schedule(XVTimer* self, XTicks step);
162 
163 
166 XTicks xvtimer_now(const XVTimer* self);
167 
168 
169 #ifdef __cplusplus
170 }
171 #endif /* __cplusplus */
172 
173 
179 #endif /* picox_multitask_xvtimer_h_ */
int32_t XTicks
システムチックを格納する型です
Definition: xtime.h:63
void(* XVTimerCallBack)(void *arg)
コールバック関数ポインタ型です
Definition: xvtimer.h:74
void xvtimer_remove_requst(XVTimer *self, XVTimerRequest *request)
リクエストを除去します
Definition: xvtimer.c:118
リストノードデータを格納するコンテナ
Definition: xintrusive_list.h:96
双方向リンリストリストノード
Definition: xintrusive_list.h:87
void xvtimer_init(XVTimer *self)
仮想タイマオブジェクトを初期化します
Definition: xvtimer.c:48
コールバックリクエスト構造体です
Definition: xvtimer.h:81
void xvtimer_add_request(XVTimer *self, XVTimerRequest *request, XVTimerCallBack callback, void *arg, XTicks delay, XTicks interval, bool once, XDeleter deleter)
コールバックリクエストを追加します
Definition: xvtimer.c:84
void xvtimer_schedule(XVTimer *self, XTicks step)
仮想タイマのカウントをstep数ぶん進めます
Definition: xvtimer.c:134
void xvtimer_deinit(XVTimer *self)
リクエストを全て除去します
Definition: xvtimer.c:72
仮想タイマー構造体です
Definition: xvtimer.h:103
void xvtimer_init_request(XVTimerRequest *request)
コールバックリクエストオブジェクトを初期化します
Definition: xvtimer.c:57
XVTimerCallBack callback
Definition: xvtimer.h:84
ノード侵入型のダブルリンクリストコンテナです。
XTicks xvtimer_now(const XVTimer *self)
仮想タイマの現在時刻を返します
Definition: xvtimer.c:200
void(* XDeleter)(void *ptr)
オブジェクトを削除する関数ポインタ型です
Definition: xstddef.h:313