MySQL  8.0.16
Source Code Documentation
my_timer.h
Go to the documentation of this file.
1 /* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License, version 2.0,
5  as published by the Free Software Foundation.
6 
7  This program is also distributed with certain software (including
8  but not limited to OpenSSL) that is licensed under separate terms,
9  as designated in a particular file or component or in included license
10  documentation. The authors of MySQL hereby grant you an additional
11  permission to link the program and your derivative works with the
12  separately licensed software that they have included with MySQL.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License, version 2.0, for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 
23 #ifndef MY_TIMER_H
24 #define MY_TIMER_H
25 
26 /**
27  @file include/my_timer.h
28 */
29 
30 #include "my_config.h"
31 
32 /* POSIX timers API. */
33 #ifdef HAVE_POSIX_TIMERS
34 #include <time.h> /* timer_t */
35 
36 typedef timer_t os_timer_t;
37 #elif defined(HAVE_KQUEUE_TIMERS)
38 #include <sys/types.h> /* uintptr_t */
39 
40 typedef uintptr_t os_timer_t;
41 #elif defined(_WIN32)
42 struct os_timer_t {
43  HANDLE timer_handle;
44  bool timer_state;
45 };
46 #endif
47 
48 /* Non-copyable timer object. */
49 struct my_timer_t {
50  /* Timer ID used to identify the timer in timer requests. */
51  os_timer_t id;
52 
53  /** Timer expiration notification function. */
55 };
56 
57 /* Initialize internal components. */
59 
60 /* Release any resources acquired. */
62 
63 /* Create a timer object. */
64 int my_timer_create(my_timer_t *timer);
65 
66 /* Set the time (in milliseconds) until the next expiration of the timer. */
67 int my_timer_set(my_timer_t *timer, unsigned long time);
68 
69 /* Cancel the timer */
70 int my_timer_cancel(my_timer_t *timer, int *state);
71 
72 /* Delete a timer object. */
73 void my_timer_delete(my_timer_t *timer);
74 
75 #endif /* MY_TIMER_H */
Definition: my_timer.h:49
void my_timer_delete(my_timer_t *timer)
Delete a timer object.
Definition: kqueue_timers.cc:221
#define HANDLE
Definition: violite.h:156
int my_timer_create(my_timer_t *timer)
Create a timer object.
Definition: kqueue_timers.cc:156
int my_timer_initialize()
Initialize internal components.
Definition: kqueue_timers.cc:112
void(* notify_function)(my_timer_t *)
Timer expiration notification function.
Definition: my_timer.h:54
os_timer_t id
Definition: my_timer.h:51
int my_timer_cancel(my_timer_t *timer, int *state)
Cancel the timer.
Definition: kqueue_timers.cc:193
t time
Definition: dbug_analyze.cc:149
int my_timer_set(my_timer_t *timer, unsigned long time)
Set the time until the next expiration of the timer.
Definition: kqueue_timers.cc:174
void my_timer_deinitialize()
Release any resources that were allocated as part of initialization.
Definition: kqueue_timers.cc:134