MySQL 9.1.0
Source Code Documentation
my_timer.h
Go to the documentation of this file.
1/* Copyright (c) 2014, 2024, 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 designed to work 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 either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef MY_TIMER_H
25#define MY_TIMER_H
26
27/**
28 @file include/my_timer.h
29*/
30
31#include "my_config.h"
32
33/* POSIX timers API. */
34#ifdef HAVE_POSIX_TIMERS
35#include <time.h> /* timer_t */
36
37typedef timer_t os_timer_t;
38#elif defined(HAVE_KQUEUE_TIMERS)
39#include <sys/types.h> /* uintptr_t */
40
41typedef uintptr_t os_timer_t;
42#elif defined(_WIN32)
43struct os_timer_t {
44 HANDLE timer_handle;
45 bool timer_state;
46};
47#endif
48
49/* Non-copyable timer object. */
50struct my_timer_t {
51 /* Timer ID used to identify the timer in timer requests. */
53
54 /** Timer expiration notification function. */
56};
57
58/* Initialize internal components. */
60
61/* Release any resources acquired. */
63
64/**
65 Create a timer object.
66
67 @param timer Location where the timer ID is returned.
68
69 @return On success, 0.
70 On error, -1 is returned, and errno is set to indicate the error.
71*/
72int my_timer_create(my_timer_t *timer);
73
74/* Set the time (in milliseconds) until the next expiration of the timer. */
75int my_timer_set(my_timer_t *timer, unsigned long time);
76
77/* Cancel the timer */
78int my_timer_cancel(my_timer_t *timer, int *state);
79
80/* Delete a timer object. */
81void my_timer_delete(my_timer_t *timer);
82
83#endif /* MY_TIMER_H */
void my_timer_deinitialize()
Release any resources that were allocated as part of initialization.
Definition: kqueue_timers.cc:135
int my_timer_initialize()
Initialize internal components.
Definition: kqueue_timers.cc:113
timer_t os_timer_t
Definition: my_timer.h:37
int my_timer_create(my_timer_t *timer)
Create a timer object.
Definition: kqueue_timers.cc:148
int my_timer_cancel(my_timer_t *timer, int *state)
Cancel the timer.
Definition: kqueue_timers.cc:185
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:166
void my_timer_delete(my_timer_t *timer)
Delete a timer object.
Definition: kqueue_timers.cc:213
Definition: my_timer.h:50
void(* notify_function)(my_timer_t *)
Timer expiration notification function.
Definition: my_timer.h:55
os_timer_t id
Definition: my_timer.h:52
Include file for Sun RPC to compile out of the box.
#define HANDLE
Definition: violite.h:159