![]() |
Home | Libraries | Author | Links |
![]() |
AccessLock.
The read access to such a resource protected by a StmAccessLock object is granted by StmReadOnlyTicket objects whereas the read/write access is granted by a StmReadWriteTicket object.
StmReadOnlyTicket objects can be obtained by an arbitrary number of threads as long as no write access is pending. A StmReadWriteTicket object can be obtained by at most one thread provided no read access is pending.
Valid objects of type StmAccessLock can be achieved only as return values of stmAccessLockCreate(). Moreover, variables of type StmAccessLock may have the value NULL
meaning invalid or undefined.
Files | |
file | StmAccessLockAdtDoc.h |
Documentation of the abstract structure data type type StmAccessLock. | |
Modules | |
Abstract Data Type StmReadOnlyTicket | |
A valid StmReadOnlyTicket grants read only access to a resource protected by a valid StmAccessLock object. | |
Abstract Data Type StmReadWriteTicket | |
A valid StmReadWriteTicket grants read and write access to a resource protected by a valid StmAccessLock object. | |
StmAccessLock Representation | |
An object of abstract data type StmAccessLock is represented as a pointer to its implementation. | |
typedef struct StmAccessLockImpl_ | StmAccessLockImpl_ |
Type name of implementation structure. | |
typedef StmAccessLockImpl_ * | StmAccessLock |
Pointer to implementation. | |
typedef const StmAccessLockImpl_ * | ConstStmAccessLock |
Pointer to constant implementation. | |
StmAccessLock Creation and Destruction | |
StmAccessLock | stmAccessLockCreate (void) |
Creation of a new StmAccessLock object. | |
int | stmAccessLockDestroy (StmAccessLock lock) |
Destruction of the StmAccessLock object lock. | |
StmAccessLock Method Functions | |
StmReadOnlyTicket | stmAccessLockTakeReadOnly (StmAccessLock lock) |
Return a StmReadOnlyTicket object granting read access for the resource protected by the StmAccessLock object lock. | |
StmReadOnlyTicket | stmAccessLockTryReadOnly (StmAccessLock lock) |
Try to return a StmReadOnlyTicket object granting read access for the resource protected by the StmAccessLock object lock. | |
StmReadWriteTicket | stmAccessLockConvertReadOnly (StmAccessLock lock, StmReadOnlyTicket ticket) |
Convert the StmReadOnlyTicket object ticket granting read access to the resource protected by the StmAccessLock object lock to a StmReadWriteTicket object granting write access to the resource and return it. | |
int | stmAccessLockGiveReadOnly (StmAccessLock lock, StmReadOnlyTicket ticket) |
Release the StmReadOnlyTicket object ticket granting read access to the resource protected by the StmAccessLock object lock. | |
StmReadWriteTicket | stmAccessLockTakeReadWrite (StmAccessLock lock) |
Return a StmReadWriteTicket object granting write access for the resource protected by the StmAccessLock object lock. | |
StmReadWriteTicket | stmAccessLockTryReadWrite (StmAccessLock lock) |
Try to return a StmReadWriteTicket object granting write access for the resource protected by the StmAccessLock object lock. | |
StmReadOnlyTicket | stmAccessLockConvertReadWrite (StmAccessLock lock, StmReadWriteTicket ticket) |
Convert the StmReadWriteTicket object ticket granting write access to the resource protected by the StmAccessLock object lock to a StmReadOnlyTicket object granting read access to the resource and return it. | |
int | stmAccessLockGiveReadWrite (StmAccessLock lock, StmReadWriteTicket ticket) |
Release the StmReadWriteTicket object ticket granting write access to the resource protected by the StmAccessLock object lock. |
typedef struct StmAccessLockImpl_ StmAccessLockImpl_ |
typedef StmAccessLockImpl_* StmAccessLock |
typedef const StmAccessLockImpl_* ConstStmAccessLock |
StmAccessLock stmAccessLockCreate | ( | void | ) |
Creation of a new StmAccessLock object.
NULL
on error. Then the variable errno
contains the error's cause. The StmAccessLock object created on success.
int stmAccessLockDestroy | ( | StmAccessLock | lock | ) |
Destruction of the StmAccessLock object lock.
[in] | lock | The StmAccessLock object to be destroyed. |
NULL
in which case the function does nothing. -1
on error. Then the variable errno
contains the error's cause.
0
on success.
StmReadOnlyTicket stmAccessLockTakeReadOnly | ( | StmAccessLock | lock | ) |
Return a StmReadOnlyTicket object granting read access for the resource protected by the StmAccessLock object lock.
[in] | lock | The StmAccessLock object. |
NULL
on error. Then the variable errno
is set to EINVAL
, if lock is invalid, or to EBUSY, if the calling thread also holds a write lock.
StmReadOnlyTicket stmAccessLockTryReadOnly | ( | StmAccessLock | lock | ) |
Try to return a StmReadOnlyTicket object granting read access for the resource protected by the StmAccessLock object lock.
[in] | lock | The StmAccessLock object. |
NULL
on error. Then the variable errno
is set to EINVAL
, if lock is invalid, to EAGAIN, if the resource is locked by a write access of another thread and/or if write accesses of other threads are pending, or to EBUSY, if the calling thread also holds a write lock.
StmReadWriteTicket stmAccessLockConvertReadOnly | ( | StmAccessLock | lock, | |
StmReadOnlyTicket | ticket | |||
) |
Convert the StmReadOnlyTicket object ticket granting read access to the resource protected by the StmAccessLock object lock to a StmReadWriteTicket object granting write access to the resource and return it.
[in] | lock | The StmAccessLock object. |
[in] | ticket | The StmReadOnlyTicket object to be converted. |
NULL
on error. Then the variable errno
is set to EINVAL
, if lock is invalid, to EPERM
, if ticket is invalid, or to EBUSY, if the calling thread held more than one read access.
int stmAccessLockGiveReadOnly | ( | StmAccessLock | lock, | |
StmReadOnlyTicket | ticket | |||
) |
Release the StmReadOnlyTicket object ticket granting read access to the resource protected by the StmAccessLock object lock.
[in] | lock | The StmAccessLock object. |
[in] | ticket | The StmReadOnlyTicket object to be released. |
0
on success.
-1
on error. Then the variable errno
is set to EINVAL
, if lock is invalid or to EPERM
, if ticket is invalid.
StmReadWriteTicket stmAccessLockTakeReadWrite | ( | StmAccessLock | lock | ) |
Return a StmReadWriteTicket object granting write access for the resource protected by the StmAccessLock object lock.
[in] | lock | The StmAccessLock object. |
NULL
on error. Then the variable errno
is set to EINVAL
, if lock is invalid, or to EBUSY, if the calling thread also holds a read lock.
StmReadWriteTicket stmAccessLockTryReadWrite | ( | StmAccessLock | lock | ) |
Try to return a StmReadWriteTicket object granting write access for the resource protected by the StmAccessLock object lock.
[in] | lock | The StmAccessLock object. |
NULL
on error. Then the variable errno
is set to EINVAL
, if lock is invalid, to EAGAIN, if the resource is locked by a write access of another thread or by read accesses of other threads, or to EBUSY, if the calling thread also holds a read lock.
StmReadOnlyTicket stmAccessLockConvertReadWrite | ( | StmAccessLock | lock, | |
StmReadWriteTicket | ticket | |||
) |
Convert the StmReadWriteTicket object ticket granting write access to the resource protected by the StmAccessLock object lock to a StmReadOnlyTicket object granting read access to the resource and return it.
[in] | lock | The StmAccessLock object. |
[in] | ticket | The StmReadWriteTicket object to be converted. |
NULL
on error. Then the variable errno
is set to EINVAL
, if lock is invalid, to EPERM
, if ticket is invalid, or to EBUSY, if the calling thread held more than one write access.
int stmAccessLockGiveReadWrite | ( | StmAccessLock | lock, | |
StmReadWriteTicket | ticket | |||
) |
Release the StmReadWriteTicket object ticket granting write access to the resource protected by the StmAccessLock object lock.
[in] | lock | The StmAccessLock object. |
[in] | ticket | The StmReadWriteTicket object to be released. |
0
on success.
-1
on error. Then the variable errno
is set to EINVAL
, if lock is invalid or to EPERM
, if ticket is invalid.
© Copyright Tom Michaelis 2002-2007
Distributed under the SysToMath Software License (See the accompanying file license.txt or a copy at www.SysToMath.com).