diff options
Diffstat (limited to 'src/include/storage/latch.h')
-rw-r--r-- | src/include/storage/latch.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/include/storage/latch.h b/src/include/storage/latch.h new file mode 100644 index 00000000000..2c697741e4d --- /dev/null +++ b/src/include/storage/latch.h @@ -0,0 +1,62 @@ +/*------------------------------------------------------------------------- + * + * latch.h + * Routines for interprocess latches + * + * + * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * $PostgreSQL: pgsql/src/include/storage/latch.h,v 1.1 2010/09/11 15:48:04 heikki Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef LATCH_H +#define LATCH_H + +#include <signal.h> + +/* + * Latch structure should be treated as opaque and only accessed through + * the public functions. It is defined here to allow embedding Latches as + * part of bigger structs. + */ +typedef struct +{ + sig_atomic_t is_set; + bool is_shared; +#ifndef WIN32 + int owner_pid; +#else + HANDLE event; +#endif +} Latch; + +/* + * prototypes for functions in latch.c + */ +extern void InitLatch(volatile Latch *latch); +extern void InitSharedLatch(volatile Latch *latch); +extern void OwnLatch(volatile Latch *latch); +extern void DisownLatch(volatile Latch *latch); +extern bool WaitLatch(volatile Latch *latch, long timeout); +extern int WaitLatchOrSocket(volatile Latch *latch, pgsocket sock, + long timeout); +extern void SetLatch(volatile Latch *latch); +extern void ResetLatch(volatile Latch *latch); +#define TestLatch(latch) (((volatile Latch *) latch)->is_set) + +extern Size LatchShmemSize(void); +extern void LatchShmemInit(void); + +/* + * Unix implementation uses SIGUSR1 for inter-process signaling, Win32 doesn't + * need this. + */ +#ifndef WIN32 +extern void latch_sigusr1_handler(void); +#else +#define latch_sigusr1_handler() +#endif + +#endif /* LATCH_H */ |