2 * File: Lock.h $XConsortium: Lock.h /main/4 1995/10/26 15:24:02 rswiston $
5 * (c) Copyright 1990, Hewlett-Packard Company, all rights reserved.
7 * (c) Copyright 1993, 1994 Hewlett-Packard Company *
8 * (c) Copyright 1993, 1994 International Business Machines Corp. *
9 * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
10 * (c) Copyright 1993, 1994 Novell, Inc. *
19 The DT lock facility provides simple exclusive locking. It
20 (as of 6/19/90) is based on the X11 selection-ownership
21 mechanism, though users of Dt locking do not need to be aware of
24 X11 server grabs are judiciously used to guarantee atomicity of
25 operations. If a process which holds a lock dies (or closes its
26 X11 server connection for some other reason), the lock will be
27 automatically released.
29 Locks are identified by a string. There is no mechanism to
30 allocate unique lock strings to clients; users must take care to
31 choose a string that will not be easily duplicated by some other
36 #define MY_LOCK "MYAPP_MY_LOCK"
40 if (_DtGetLock (display, MY_LOCK)) {
41 <do whatever it is I want to do>
42 _DtReleaseLock (display, MY_LOCK);
49 extern int _DtGetLock (
55 _DtGetLock attempts to get the specified lock. If nobody holds
56 the lock, _DtGetLock will obtain the lock and return 1. If
57 somebody else already holds the lock, the lock will not be
58 disturbed and _DtGetLock will return 0.
60 If the process which owns a lock dies (or closes its X11 server
61 connection), the lock will be automatically released. To
62 explicitly release a lock, use _DtReleaseLock.
67 success = _DtGetLock (display, lock);
69 int success; Returns 1 if the lock is obtained,
72 Display *display; The X11 server connection which will
75 char *lock; The string which names the lock.
78 extern void _DtReleaseLock (
84 _DtReleaseLock releases a lock obtained by _DtGetLock.
86 WARNING!! It is perfectly legal for one process to release
87 a lock held by another process. By convention you should only
88 release locks previously obtained by your process from _DtGetLock
89 unless you are playing God and know what you are doing.
93 (void) _DtReleaseLock (display, lock);
95 Display *display; The X11 server connection which holds
98 char *lock; The string which names the lock.
101 extern int _DtTestLock (
107 _DtTestLock returns a status indicating whether anybody holds the
112 status = _DtTestLock (display, lock);
114 int success; Returns 1 if anybody holds the lock,
117 Display *display; The X11 server connection.
119 char *lock; The string which names the lock.
122 #endif /* _Dt_lock_h */
123 /* Do not add anything after this endif. */