PostgreSQL Source Code  git master
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-2021, 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 */
36  /* First user-definable timeout reason */
38  /* Maximum number of timeout reasons */
40 } TimeoutId;
41 
42 /* callback function signature */
43 typedef void (*timeout_handler_proc) (void);
44 
45 /*
46  * Parameter structure for setting multiple timeouts at once
47  */
48 typedef enum TimeoutType
49 {
52 } TimeoutType;
53 
54 typedef struct
55 {
56  TimeoutId id; /* timeout to set */
57  TimeoutType type; /* TMPARAM_AFTER or TMPARAM_AT */
58  int delay_ms; /* only used for TMPARAM_AFTER */
59  TimestampTz fin_time; /* only used for TMPARAM_AT */
61 
62 /*
63  * Parameter structure for clearing multiple timeouts at once
64  */
65 typedef struct
66 {
67  TimeoutId id; /* timeout to clear */
68  bool keep_indicator; /* keep the indicator flag? */
70 
71 /* timeout setup */
72 extern void InitializeTimeouts(void);
74 extern void reschedule_timeouts(void);
75 
76 /* timeout operation */
77 extern void enable_timeout_after(TimeoutId id, int delay_ms);
78 extern void enable_timeout_at(TimeoutId id, TimestampTz fin_time);
79 extern void enable_timeouts(const EnableTimeoutParams *timeouts, int count);
80 extern void disable_timeout(TimeoutId id, bool keep_indicator);
81 extern void disable_timeouts(const DisableTimeoutParams *timeouts, int count);
82 extern void disable_all_timeouts(bool keep_indicators);
83 
84 /* accessors */
85 extern bool get_timeout_active(TimeoutId id);
86 extern bool get_timeout_indicator(TimeoutId id, bool reset_indicator);
89 
90 #endif /* TIMEOUT_H */
TimeoutId id
Definition: timeout.h:56
void disable_timeout(TimeoutId id, bool keep_indicator)
Definition: timeout.c:621
int64 TimestampTz
Definition: timestamp.h:39
TimeoutType type
Definition: timeout.h:57
void disable_all_timeouts(bool keep_indicators)
Definition: timeout.c:687
TimestampTz get_timeout_start_time(TimeoutId id)
Definition: timeout.c:749
void enable_timeout_at(TimeoutId id, TimestampTz fin_time)
Definition: timeout.c:549
TimestampTz get_timeout_finish_time(TimeoutId id)
Definition: timeout.c:763
void enable_timeout_after(TimeoutId id, int delay_ms)
Definition: timeout.c:524
void(* timeout_handler_proc)(void)
Definition: timeout.h:43
bool get_timeout_indicator(TimeoutId id, bool reset_indicator)
Definition: timeout.c:729
TimeoutId id
Definition: timeout.h:67
void disable_timeouts(const DisableTimeoutParams *timeouts, int count)
Definition: timeout.c:654
TimestampTz fin_time
Definition: timeout.h:59
TimeoutId
Definition: timeout.h:23
TimeoutId RegisterTimeout(TimeoutId id, timeout_handler_proc handler)
Definition: timeout.c:469
TimeoutType
Definition: timeout.h:48
void reschedule_timeouts(void)
Definition: timeout.c:504
bool get_timeout_active(TimeoutId id)
Definition: timeout.c:716
void InitializeTimeouts(void)
Definition: timeout.c:435
void enable_timeouts(const EnableTimeoutParams *timeouts, int count)
Definition: timeout.c:572