#include <opennurbs_sleeplock.h>
◆ anonymous enum
anonymous enum : unsigned int |
Enumerator |
---|
DefaultWaitInterval | summary> The default ON_SleepLock interval is 1/20 of a second to wait between attempts to obtain the lock. /summary> summary> A ON_SleepLock interval of 1 millisecond (1/1000 second). /summary>
|
OneMillisecond | summary> A ON_SleepLock interval of 1 second. /summary>
|
OneSecond | summary> A ON_SleepLock interval of 1 minute. /summary>
|
OneMinute | |
◆ ON_SleepLock()
ON_SleepLock::ON_SleepLock |
( |
| ) |
|
|
default |
◆ ~ON_SleepLock()
ON_SleepLock::~ON_SleepLock |
( |
| ) |
|
|
default |
◆ GetLock() [1/3]
bool ON_SleepLock::GetLock |
( |
| ) |
|
◆ GetLock() [2/3]
bool ON_SleepLock::GetLock |
( |
unsigned int |
interval_wait_msecs, |
|
|
unsigned int |
max_wait_msecs |
|
) |
| |
Description: Gets the lock using a the specified waiting interval and maximum waiting time. Parameters: interval_wait_msecs - [in] number of milliseconds to wait between checking for the lock. If interval_wait_msecs is 0, then ON_SleepLock::DefaultWaitInterval is used. If interval_wait_msecs > max_wait_msecs > 0, then one attempt is made to get the lock. max_wait_msecs - [in] maximum number of milliseconds to wait for lock. If max_wait_msecs is 0, then no maximum waiting time is used. Returns: True if the lock is obtained. False if the maximum waiting time expired without getting the lock.
If GetLock() returns true, then you must call ReturnLock() when finished using the protected resource. If GetLock() returns false, then you must not call ReturnLock(). Remarks: It is easy and clear to people reading your code if you use values like ON_SleepLock::OneSecond, ON_SleepLock::OneSecond/10, 47*ON_SleepLock::OneSecond, ON_SleepLock::OneMinute, or ON_SleepLock::OneMinute/3 to specify the values for interval_wait_msecs and max_wait_msecs.
◆ GetLock() [3/3]
bool ON_SleepLock::GetLock |
( |
unsigned int |
interval_wait_msecs, |
|
|
unsigned int |
max_wait_msecs, |
|
|
bool |
bStealLockAfterWaiting |
|
) |
| |
◆ GetLockOrReturnFalse()
bool ON_SleepLock::GetLockOrReturnFalse |
( |
| ) |
|
Description: Attempts to get the lock a single time. Returns: True if the lock was acquired. False if the lock was not acquired because it was already locked. Remarks: If GetLockOrReturnFalse() returns true, then you must call ReturnLock() when finished using the protected resource. If GetLockOrReturnFalse() returns false, then you must not call ReturnLock().
◆ IsLocked()
bool ON_SleepLock::IsLocked |
( |
| ) |
const |
◆ ReturnLock()
bool ON_SleepLock::ReturnLock |
( |
| ) |
|
Description: Unconditionally returns the lock. Returns: True if the lock was changed from locked to unlocked. False if the lock was already unlocked.