PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
timeout.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * timeout.h
4  * Routines to multiplex SIGALRM interrupts for multiple timeout reasons.
5  *
6  *
7  * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/utils/timeout.h
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef TIMEOUT_H
15 #define TIMEOUT_H
16 
17 #include "datatype/timestamp.h"
18 
19 /*
20  * Identifiers for timeout reasons. Note that in case multiple timeouts
21  * trigger at the same time, they are serviced in the order of this enum.
22  */
23 typedef enum TimeoutId
24 {
25  /* Predefined timeout reasons */
34  /* First user-definable timeout reason */
36  /* Maximum number of timeout reasons */
38 } TimeoutId;
39 
40 /* callback function signature */
41 typedef void (*timeout_handler_proc) (void);
42 
43 /*
44  * Parameter structure for setting multiple timeouts at once
45  */
46 typedef enum TimeoutType
47 {
50 } TimeoutType;
51 
52 typedef struct
53 {
54  TimeoutId id; /* timeout to set */
55  TimeoutType type; /* TMPARAM_AFTER or TMPARAM_AT */
56  int delay_ms; /* only used for TMPARAM_AFTER */
57  TimestampTz fin_time; /* only used for TMPARAM_AT */
59 
60 /*
61  * Parameter structure for clearing multiple timeouts at once
62  */
63 typedef struct
64 {
65  TimeoutId id; /* timeout to clear */
66  bool keep_indicator; /* keep the indicator flag? */
68 
69 /* timeout setup */
70 extern void InitializeTimeouts(void);
72 extern void reschedule_timeouts(void);
73 
74 /* timeout operation */
75 extern void enable_timeout_after(TimeoutId id, int delay_ms);
76 extern void enable_timeout_at(TimeoutId id, TimestampTz fin_time);
77 extern void enable_timeouts(const EnableTimeoutParams *timeouts, int count);
78 extern void disable_timeout(TimeoutId id, bool keep_indicator);
79 extern void disable_timeouts(const DisableTimeoutParams *timeouts, int count);
80 extern void disable_all_timeouts(bool keep_indicators);
81 
82 /* accessors */
83 extern bool get_timeout_indicator(TimeoutId id, bool reset_indicator);
86 
87 #endif /* TIMEOUT_H */
TimeoutId id
Definition: timeout.h:54
void disable_timeout(TimeoutId id, bool keep_indicator)
Definition: timeout.c:525
TimeoutType type
Definition: timeout.h:55
void disable_all_timeouts(bool keep_indicators)
Definition: timeout.c:596
TimestampTz get_timeout_start_time(TimeoutId id)
Definition: timeout.c:653
void enable_timeout_at(TimeoutId id, TimestampTz fin_time)
Definition: timeout.c:453
TimestampTz get_timeout_finish_time(TimeoutId id)
Definition: timeout.c:667
void enable_timeout_after(TimeoutId id, int delay_ms)
Definition: timeout.c:428
double TimestampTz
Definition: timestamp.h:51
bool get_timeout_indicator(TimeoutId id, bool reset_indicator)
Definition: timeout.c:633
TimeoutId id
Definition: timeout.h:65
void disable_timeouts(const DisableTimeoutParams *timeouts, int count)
Definition: timeout.c:561
TimestampTz fin_time
Definition: timeout.h:57
TimeoutId
Definition: timeout.h:23
TimeoutId RegisterTimeout(TimeoutId id, timeout_handler_proc handler)
Definition: timeout.c:373
TimeoutType
Definition: timeout.h:46
void reschedule_timeouts(void)
Definition: timeout.c:408
void InitializeTimeouts(void)
Definition: timeout.c:340
void enable_timeouts(const EnableTimeoutParams *timeouts, int count)
Definition: timeout.c:476
void(* timeout_handler_proc)(void)
Definition: timeout.h:41