Motr  M0
timer.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2013-2020 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
23 #pragma once
24 
25 #ifndef __MOTR_LIB_TIMER_H__
26 #define __MOTR_LIB_TIMER_H__
27 
28 #include "lib/types.h"
29 #include "lib/tlist.h" /* m0_tl */
30 #include "lib/mutex.h" /* m0_mutex */
31 
96 typedef unsigned long (*m0_timer_callback_t)(unsigned long data);
97 struct m0_timer;
98 struct m0_timer_locality;
99 
107 };
108 
124 };
125 
127  int (*tmr_init)(struct m0_timer *timer, struct m0_timer_locality *loc);
128  void (*tmr_fini)(struct m0_timer *timer);
129  void (*tmr_start)(struct m0_timer *timer);
130  void (*tmr_stop)(struct m0_timer *timer);
131 };
132 
133 #ifndef __KERNEL__
134 #include "lib/user_space/timer.h"
135 #else
136 #include "lib/linux_kernel/timer.h"
137 #endif
138 
154 M0_INTERNAL int m0_timer_init(struct m0_timer *timer,
155  enum m0_timer_type type,
156  struct m0_timer_locality *loc,
157  m0_timer_callback_t callback,
158  unsigned long data);
159 
168 M0_INTERNAL void m0_timer_start(struct m0_timer *timer,
169  m0_time_t expire);
170 
179 M0_INTERNAL void m0_timer_stop(struct m0_timer *timer);
180 
184 M0_INTERNAL bool m0_timer_is_started(const struct m0_timer *timer);
185 
192 M0_INTERNAL void m0_timer_fini(struct m0_timer *timer);
193 
199 M0_INTERNAL void m0_timer_callback_execute(struct m0_timer *timer);
200 
205 M0_INTERNAL void m0_timer_locality_init(struct m0_timer_locality *loc);
206 
213 M0_INTERNAL void m0_timer_locality_fini(struct m0_timer_locality *loc);
214 
222 M0_INTERNAL int m0_timer_thread_attach(struct m0_timer_locality *loc);
223 
232 M0_INTERNAL void m0_timer_thread_detach(struct m0_timer_locality *loc);
233 
235 /* __MOTR_LIB_TIMER_H__ */
236 #endif
237 
238 /*
239  * Local variables:
240  * c-indentation-style: "K&R"
241  * c-basic-offset: 8
242  * tab-width: 8
243  * fill-column: 80
244  * scroll-step: 1
245  * End:
246  */
M0_INTERNAL void m0_timer_locality_fini(struct m0_timer_locality *loc)
Definition: timer.c:84
void(* tmr_start)(struct m0_timer *timer)
Definition: timer.h:129
M0_INTERNAL int m0_timer_thread_attach(struct m0_timer_locality *loc)
Definition: timer.c:127
int(* tmr_init)(struct m0_timer *timer, struct m0_timer_locality *loc)
Definition: timer.h:127
uint64_t m0_time_t
Definition: time.h:37
m0_timer_state
Definition: timer.h:113
struct m0_bufvec data
Definition: di.c:40
M0_INTERNAL void m0_timer_thread_detach(struct m0_timer_locality *loc)
Definition: timer.c:153
M0_INTERNAL int m0_timer_init(struct m0_timer *timer, enum m0_timer_type type, struct m0_timer_locality *loc, m0_timer_callback_t callback, unsigned long data)
Definition: timer.c:39
Definition: timer.h:39
M0_INTERNAL void m0_timer_fini(struct m0_timer *timer)
Definition: timer.c:65
M0_INTERNAL void m0_timer_stop(struct m0_timer *timer)
Definition: timer.c:86
M0_INTERNAL void m0_timer_start(struct m0_timer *timer, m0_time_t expire)
Definition: timer.c:75
m0_timer_type
Definition: timer.h:103
M0_INTERNAL bool m0_timer_is_started(const struct m0_timer *timer)
Definition: timer.c:94
unsigned long(* m0_timer_callback_t)(unsigned long data)
Definition: timer.h:96
M0_INTERNAL void m0_timer_locality_init(struct m0_timer_locality *loc)
Definition: timer.c:75
void(* tmr_fini)(struct m0_timer *timer)
Definition: timer.h:128
void(* tmr_stop)(struct m0_timer *timer)
Definition: timer.h:130
int type
Definition: dir.c:1031
M0_INTERNAL void m0_timer_callback_execute(struct m0_timer *timer)
Definition: timer.c:99