| 1 |
@node Readers-writer locks |
| 2 |
@subsection Readers-writer locks |
| 3 |
|
| 4 |
@ftindex ecl-read-write-lock |
| 5 |
@cindex Readers-writer locks |
| 6 |
@cindex Shared-exclusive locks |
| 7 |
|
| 8 |
Readers-writer (or shared-exclusive ) locks allow concurrent access |
| 9 |
for read-only operations, while write operations require exclusive |
| 10 |
access. @code{mp:rwlock} is non-recursive and cannot be used together |
| 11 |
with condition variables. |
| 12 |
|
| 13 |
@node Readers-writer locks dictionary |
| 14 |
@subsection Read-Write locks dictionary |
| 15 |
|
| 16 |
|
| 17 |
@cppdef ecl_make_rwlock |
| 18 |
|
| 19 |
@deftypefun cl_object ecl_make_rwlock (cl_object name) |
| 20 |
C/C++ equivalent of @coderef{mp:make-rwlock} without @code{key} arguments. |
| 21 |
|
| 22 |
See @coderef{mp:make-rwlock}. |
| 23 |
@end deftypefun |
| 24 |
|
| 25 |
|
| 26 |
@lspdef mp:make-rwlock |
| 27 |
|
| 28 |
@defun mp:make-rwlock &key name |
| 29 |
Creates a rwlock named @var{name}. |
| 30 |
@end defun |
| 31 |
|
| 32 |
|
| 33 |
@cppdef mp_rwlock_name |
| 34 |
@lspdef mp:rwlock-name |
| 35 |
|
| 36 |
@deftypefun cl_object mp_rwlock_name (cl_object lock) |
| 37 |
@end deftypefun |
| 38 |
|
| 39 |
@defun mp:rwlock-name lock |
| 40 |
Returns the name of @var{lock}. |
| 41 |
@end defun |
| 42 |
|
| 43 |
|
| 44 |
@cppdef mp_get_rwlock_read_wait |
| 45 |
@cppdef mp_get_rwlock_read_nowait |
| 46 |
@lspdef mp:get-rwlock-read |
| 47 |
|
| 48 |
@deftypefun cl_object mp_get_rwlock_read_wait (cl_object lock) |
| 49 |
Acquires @var{lock} (blocks if @var{lock} is already taken with |
| 50 |
@coderef{mp:get-rwlock-write}. Lock may be acquired by multiple |
| 51 |
readers). Returns @code{ECL_T}. |
| 52 |
@end deftypefun |
| 53 |
|
| 54 |
@deftypefun cl_object mp_get_rwlock_read_nowait |
| 55 |
Tries to acquire @var{lock}. If @var{lock} is already taken with |
| 56 |
@coderef{mp:get-rwlock-write} returns @code{ECL_NIL}, otherwise |
| 57 |
@code{ECL_T}. |
| 58 |
@end deftypefun |
| 59 |
|
| 60 |
@defun mp:get-rwlock-read lock &optional (wait t) |
| 61 |
Tries to acquire @var{lock}. @var{wait} indicates whenever function |
| 62 |
should block or give up if @var{lock} is already taken with |
| 63 |
@coderef{mp:get-rwlock-write}. |
| 64 |
@end defun |
| 65 |
|
| 66 |
|
| 67 |
@cppdef mp_get_rwlock_write_wait |
| 68 |
@cppdef mp_get_rwlock_write_nowait |
| 69 |
@lspdef mp:get-rwlock-write |
| 70 |
|
| 71 |
@deftypefun cl_object mp_get_rwlock_write_wait (cl_object lock) |
| 72 |
Acquires @var{lock} (blocks if @var{lock} is already taken). Returns |
| 73 |
@code{ECL_T}. |
| 74 |
@end deftypefun |
| 75 |
|
| 76 |
@deftypefun cl_object mp_get_rwlock_write_nowait |
| 77 |
Tries to acquire @var{lock}. If @var{lock} is already taken returns |
| 78 |
@code{ECL_NIL}, otherwise @code{ECL_T}. |
| 79 |
@end deftypefun |
| 80 |
|
| 81 |
@defun mp:get-rwlock-write lock &optional (wait t) |
| 82 |
Tries to acquire @var{lock}. @var{wait} indicates whenever function |
| 83 |
should block or give up if @var{lock} is already taken. |
| 84 |
@end defun |
| 85 |
|
| 86 |
|
| 87 |
@cppdef mp_giveup_rwlock_read |
| 88 |
@cppdef mp_giveup_rwlock_write |
| 89 |
|
| 90 |
@lspdef mp:giveup-rwlock-read |
| 91 |
@lspdef mp:giveup-rwlock-write |
| 92 |
|
| 93 |
|
| 94 |
@deftypefun cl_object mp_giveup_rwlock_read (cl_object lock) |
| 95 |
@deftypefunx cl_object mp_giveup_rwlock_write (cl_object lock) |
| 96 |
@end deftypefun |
| 97 |
|
| 98 |
@defun mp:giveup-rwlock-read lock |
| 99 |
@defunx mp:giveup-rwlock-write lock |
| 100 |
Release @var{lock}. |
| 101 |
@end defun |
| 102 |
|
| 103 |
|
| 104 |
@lspdef mp:with-rwlock |
| 105 |
|
| 106 |
@defmac mp:with-rwlock (lock operation) &body body |
| 107 |
Acquire rwlock for the dynamic scope of @var{body} for operation |
| 108 |
@var{operation}, which is executed with the lock held by current |
| 109 |
thread. Returns the values of body. |
| 110 |
|
| 111 |
Valid values of argument @var{operation} are @code{:read} or |
| 112 |
@code{:write} (for reader and writer access accordingly). |
| 113 |
@end defmac |