]> granicus.if.org Git - postgresql/blob - src/include/utils/timeout.h
Add GUC and storage parameter to set the maximum size of GIN pending list.
[postgresql] / src / include / utils / timeout.h
1 /*-------------------------------------------------------------------------
2  *
3  * timeout.h
4  *        Routines to multiplex SIGALRM interrupts for multiple timeout reasons.
5  *
6  *
7  * Portions Copyright (c) 1996-2014, 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 */
26         STARTUP_PACKET_TIMEOUT,
27         DEADLOCK_TIMEOUT,
28         LOCK_TIMEOUT,
29         STATEMENT_TIMEOUT,
30         STANDBY_DEADLOCK_TIMEOUT,
31         STANDBY_TIMEOUT,
32         /* First user-definable timeout reason */
33         USER_TIMEOUT,
34         /* Maximum number of timeout reasons */
35         MAX_TIMEOUTS = 16
36 } TimeoutId;
37
38 /* callback function signature */
39 typedef void (*timeout_handler_proc) (void);
40
41 /*
42  * Parameter structure for setting multiple timeouts at once
43  */
44 typedef enum TimeoutType
45 {
46         TMPARAM_AFTER,
47         TMPARAM_AT
48 } TimeoutType;
49
50 typedef struct
51 {
52         TimeoutId       id;                             /* timeout to set */
53         TimeoutType type;                       /* TMPARAM_AFTER or TMPARAM_AT */
54         int                     delay_ms;               /* only used for TMPARAM_AFTER */
55         TimestampTz fin_time;           /* only used for TMPARAM_AT */
56 } EnableTimeoutParams;
57
58 /*
59  * Parameter structure for clearing multiple timeouts at once
60  */
61 typedef struct
62 {
63         TimeoutId       id;                             /* timeout to clear */
64         bool            keep_indicator; /* keep the indicator flag? */
65 } DisableTimeoutParams;
66
67 /* timeout setup */
68 extern void InitializeTimeouts(void);
69 extern TimeoutId RegisterTimeout(TimeoutId id, timeout_handler_proc handler);
70 extern void reschedule_timeouts(void);
71
72 /* timeout operation */
73 extern void enable_timeout_after(TimeoutId id, int delay_ms);
74 extern void enable_timeout_at(TimeoutId id, TimestampTz fin_time);
75 extern void enable_timeouts(const EnableTimeoutParams *timeouts, int count);
76 extern void disable_timeout(TimeoutId id, bool keep_indicator);
77 extern void disable_timeouts(const DisableTimeoutParams *timeouts, int count);
78 extern void disable_all_timeouts(bool keep_indicators);
79
80 /* accessors */
81 extern bool get_timeout_indicator(TimeoutId id, bool reset_indicator);
82 extern TimestampTz get_timeout_start_time(TimeoutId id);
83
84 #endif   /* TIMEOUT_H */