#ifndef TIMEOUT_H
#define TIMEOUT_H
#include "datatype/timestamp.h"
typedef enum TimeoutId
{
STARTUP_PACKET_TIMEOUT,
DEADLOCK_TIMEOUT,
LOCK_TIMEOUT,
STATEMENT_TIMEOUT,
STANDBY_DEADLOCK_TIMEOUT,
STANDBY_TIMEOUT,
STANDBY_LOCK_TIMEOUT,
IDLE_IN_TRANSACTION_SESSION_TIMEOUT,
TRANSACTION_TIMEOUT,
IDLE_SESSION_TIMEOUT,
IDLE_STATS_UPDATE_TIMEOUT,
CLIENT_CONNECTION_CHECK_TIMEOUT,
STARTUP_PROGRESS_TIMEOUT,
USER_TIMEOUT,
MAX_TIMEOUTS = USER_TIMEOUT + 10
} TimeoutId;
typedef void (*timeout_handler_proc) (void);
typedef enum TimeoutType
{
TMPARAM_AFTER,
TMPARAM_AT,
TMPARAM_EVERY,
} TimeoutType;
typedef struct
{
TimeoutId id;
TimeoutType type;
int delay_ms;
TimestampTz fin_time;
} EnableTimeoutParams;
typedef struct
{
TimeoutId id;
bool keep_indicator;
} DisableTimeoutParams;
extern void InitializeTimeouts(void);
extern TimeoutId RegisterTimeout(TimeoutId id, timeout_handler_proc handler);
extern void reschedule_timeouts(void);
extern void enable_timeout_after(TimeoutId id, int delay_ms);
extern void enable_timeout_every(TimeoutId id, TimestampTz fin_time,
int delay_ms);
extern void enable_timeout_at(TimeoutId id, TimestampTz fin_time);
extern void enable_timeouts(const EnableTimeoutParams *timeouts, int count);
extern void disable_timeout(TimeoutId id, bool keep_indicator);
extern void disable_timeouts(const DisableTimeoutParams *timeouts, int count);
extern void disable_all_timeouts(bool keep_indicators);
extern bool get_timeout_active(TimeoutId id);
extern bool get_timeout_indicator(TimeoutId id, bool reset_indicator);
extern TimestampTz get_timeout_start_time(TimeoutId id);
extern TimestampTz get_timeout_finish_time(TimeoutId id);
#endif