~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to src/include/storage/lwlock.h

  • Committer: alvherre
  • Date: 2005-12-16 21:24:52 UTC
  • Revision ID: svn-v4:db760fc0-0f08-0410-9d63-cc6633f64896:trunk:1
Initial import of the REL8_0_3 sources from the Pgsql CVS repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*-------------------------------------------------------------------------
 
2
 *
 
3
 * lwlock.h
 
4
 *        Lightweight lock manager
 
5
 *
 
6
 *
 
7
 * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
 
8
 * Portions Copyright (c) 1994, Regents of the University of California
 
9
 *
 
10
 * $PostgreSQL: pgsql/src/include/storage/lwlock.h,v 1.16 2004-12-31 22:03:42 pgsql Exp $
 
11
 *
 
12
 *-------------------------------------------------------------------------
 
13
 */
 
14
#ifndef LWLOCK_H
 
15
#define LWLOCK_H
 
16
 
 
17
/*
 
18
 * We have a number of predefined LWLocks, plus a bunch of LWLocks that are
 
19
 * dynamically assigned (for shared buffers).  The LWLock structures live
 
20
 * in shared memory (since they contain shared data) and are identified by
 
21
 * values of this enumerated type.      We abuse the notion of an enum somewhat
 
22
 * by allowing values not listed in the enum declaration to be assigned.
 
23
 * The extra value MaxDynamicLWLock is there to keep the compiler from
 
24
 * deciding that the enum can be represented as char or short ...
 
25
 */
 
26
typedef enum LWLockId
 
27
{
 
28
        BufMgrLock,
 
29
        LockMgrLock,
 
30
        OidGenLock,
 
31
        XidGenLock,
 
32
        SInvalLock,
 
33
        FreeSpaceLock,
 
34
        MMCacheLock,
 
35
        WALInsertLock,
 
36
        WALWriteLock,
 
37
        ControlFileLock,
 
38
        CheckpointLock,
 
39
        CheckpointStartLock,
 
40
        CLogControlLock,
 
41
        SubtransControlLock,
 
42
        RelCacheInitLock,
 
43
        BgWriterCommLock,
 
44
 
 
45
        NumFixedLWLocks,                        /* must be last except for
 
46
                                                                 * MaxDynamicLWLock */
 
47
 
 
48
        MaxDynamicLWLock = 1000000000
 
49
} LWLockId;
 
50
 
 
51
 
 
52
typedef enum LWLockMode
 
53
{
 
54
        LW_EXCLUSIVE,
 
55
        LW_SHARED
 
56
} LWLockMode;
 
57
 
 
58
 
 
59
#ifdef LOCK_DEBUG
 
60
extern bool Trace_lwlocks;
 
61
#endif
 
62
 
 
63
extern LWLockId LWLockAssign(void);
 
64
extern void LWLockAcquire(LWLockId lockid, LWLockMode mode);
 
65
extern bool LWLockConditionalAcquire(LWLockId lockid, LWLockMode mode);
 
66
extern void LWLockRelease(LWLockId lockid);
 
67
extern void LWLockReleaseAll(void);
 
68
extern bool LWLockHeldByMe(LWLockId lockid);
 
69
 
 
70
extern int      NumLWLocks(void);
 
71
extern int      LWLockShmemSize(void);
 
72
extern void CreateLWLocks(void);
 
73
 
 
74
#endif   /* LWLOCK_H */