MySQL  8.0.27
Source Code Documentation
my_timer.h
Go to the documentation of this file.
1 /* Copyright (c) 2014, 2021, Oracle and/or its affiliates.
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. */
52 
53  /** Timer expiration notification function. */
55 };
56 
57 /* Initialize internal components. */
59 
60 /* Release any resources acquired. */
62 
63 /**
64  Create a timer object.
65 
66  @param timer Location where the timer ID is returned.
67 
68  @return On success, 0.
69  On error, -1 is returned, and errno is set to indicate the error.
70 */
71 int my_timer_create(my_timer_t *timer);
72 
73 /* Set the time (in milliseconds) until the next expiration of the timer. */
74 int my_timer_set(my_timer_t *timer, unsigned long time);
75 
76 /* Cancel the timer */
77 int my_timer_cancel(my_timer_t *timer, int *state);
78 
79 /* Delete a timer object. */
80 void my_timer_delete(my_timer_t *timer);
81 
82 #endif /* MY_TIMER_H */
void my_timer_deinitialize()
Release any resources that were allocated as part of initialization.
Definition: kqueue_timers.cc:134
int my_timer_initialize()
Initialize internal components.
Definition: kqueue_timers.cc:112
timer_t os_timer_t
Definition: my_timer.h:36
int my_timer_create(my_timer_t *timer)
Create a timer object.
Definition: kqueue_timers.cc:147
int my_timer_cancel(my_timer_t *timer, int *state)
Cancel the timer.
Definition: kqueue_timers.cc:184
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:165
void my_timer_delete(my_timer_t *timer)
Delete a timer object.
Definition: kqueue_timers.cc:212
Definition: my_timer.h:49
void(* notify_function)(my_timer_t *)
Timer expiration notification function.
Definition: my_timer.h:54
os_timer_t id
Definition: my_timer.h:51
Include file for Sun RPC to compile out of the box.
#define HANDLE
Definition: violite.h:158