1 /*-------------------------------------------------------------------------
4 * Routines to multiplex SIGALRM interrupts for multiple timeout reasons.
7 * Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * src/include/utils/timeout.h
12 *-------------------------------------------------------------------------
17 #include "datatype/timestamp.h"
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.
23 typedef enum TimeoutId
25 /* Predefined timeout reasons */
26 STARTUP_PACKET_TIMEOUT,
30 STANDBY_DEADLOCK_TIMEOUT,
32 /* First user-definable timeout reason */
34 /* Maximum number of timeout reasons */
38 /* callback function signature */
39 typedef void (*timeout_handler_proc) (void);
42 * Parameter structure for setting multiple timeouts at once
44 typedef enum TimeoutType
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;
59 * Parameter structure for clearing multiple timeouts at once
63 TimeoutId id; /* timeout to clear */
64 bool keep_indicator; /* keep the indicator flag? */
65 } DisableTimeoutParams;
68 extern void InitializeTimeouts(void);
69 extern TimeoutId RegisterTimeout(TimeoutId id, timeout_handler_proc handler);
70 extern void reschedule_timeouts(void);
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);
81 extern bool get_timeout_indicator(TimeoutId id, bool reset_indicator);
82 extern TimestampTz get_timeout_start_time(TimeoutId id);
84 #endif /* TIMEOUT_H */