|
sbuild
1.6.10
|
Advisory locking. More...
#include <sbuild-lock.h>
Inheritance diagram for sbuild::lock:Public Types | |
| enum | type { LOCK_SHARED = F_RDLCK, LOCK_EXCLUSIVE = F_WRLCK, LOCK_NONE = F_UNLCK } |
| Lock type. More... | |
| enum | error_code { TIMEOUT_HANDLER, TIMEOUT_SET, TIMEOUT_CANCEL, LOCK, UNLOCK, LOCK_TIMEOUT, UNLOCK_TIMEOUT, DEVICE_LOCK, DEVICE_LOCK_TIMEOUT, DEVICE_TEST, DEVICE_UNLOCK, DEVICE_UNLOCK_TIMEOUT } |
| Error codes. More... | |
| typedef custom_error< error_code > | error |
| Exception type. | |
Public Member Functions | |
| virtual void | set_lock (type lock_type, unsigned int timeout)=0 |
| Acquire a lock. More... | |
| virtual void | unset_lock ()=0 |
| Release a lock. More... | |
Protected Member Functions | |
| lock () | |
| The constructor. | |
| virtual | ~lock () |
| The destructor. | |
| void | set_alarm () |
| Set the SIGALARM handler. More... | |
| void | clear_alarm () |
| Restore the state of SIGALRM prior to starting lock acquisition. | |
| void | set_timer (struct itimerval const &timer) |
| Set up an itimer for future expiry. More... | |
| void | unset_timer () |
| Remove any itimer currently set up. More... | |
Private Attributes | |
| struct sigaction | saved_signals |
| Signals saved during timeout. | |
Advisory locking.
This class defines a simple interface for shared and exclusive locks.
Error codes.
| enum sbuild::lock::type |
|
protected |
Set the SIGALARM handler.
An error will be thrown on failure.
References saved_signals, and TIMEOUT_HANDLER.
Referenced by set_timer().
Here is the caller graph for this function:
|
pure virtual |
Acquire a lock.
| lock_type | the type of lock to acquire. |
| timeout | the time in seconds to wait on the lock. |
Implemented in sbuild::file_lock.
|
protected |
Set up an itimer for future expiry.
This is used to interrupt system calls. This will set a handler for SIGALRM as a side effect (using set_alarm).
An error will be thrown on failure.
| timer | the timeout to set. |
References clear_alarm(), set_alarm(), and TIMEOUT_SET.
Referenced by sbuild::file_lock::set_lock().
Here is the caller graph for this function:
|
pure virtual |
Release a lock.
This is equivalent to set_lock with a lock_type of LOCK_NONE and a timeout of 0.
Implemented in sbuild::file_lock.
|
protected |
Remove any itimer currently set up.
This will clear any SIGALRM handler (using clear_alarm).
An error will be thrown on failure.
References clear_alarm(), and TIMEOUT_CANCEL.
Referenced by sbuild::file_lock::set_lock().
Here is the caller graph for this function:
1.8.9.1