Rhino C++ API  7.21
Public Types | Public Member Functions | List of all members
ON_SleepLock Class Reference

#include <opennurbs_sleeplock.h>

Public Types

enum  : unsigned int { DefaultWaitInterval = 50, OneMillisecond = 1, OneSecond = 1000, OneMinute = 60000 }
 

Public Member Functions

 ON_SleepLock ()=default
 
 ~ON_SleepLock ()=default
 
bool GetLock ()
 
bool GetLock (unsigned int interval_wait_msecs, unsigned int max_wait_msecs)
 
bool GetLock (unsigned int interval_wait_msecs, unsigned int max_wait_msecs, bool bStealLockAfterWaiting)
 
bool GetLockOrReturnFalse ()
 
bool IsLocked () const
 
bool ReturnLock ()
 

Member Enumeration Documentation

◆ 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 

Constructor & Destructor Documentation

◆ ON_SleepLock()

ON_SleepLock::ON_SleepLock ( )
default

◆ ~ON_SleepLock()

ON_SleepLock::~ON_SleepLock ( )
default

Member Function Documentation

◆ GetLock() [1/3]

bool ON_SleepLock::GetLock ( )

Description: Gets the lock using a ON_SleepLock::DefaultWaitInterval millisecond wait interval with no maximum waiting time. Returns: This version of GetLock() always returns true. Remarks: You must call ReturnLock() when finished using the protected resource.

◆ 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 wating 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 aquired. False if the lock was not aquired 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

Description: ON_SleepLock::IsLocked() is not reliable. Do not use it. It will be deleted in the next SDK. Returns: An unreliable value.

Deprecated:
ON_SleepLock::IsLocked() is not reliable. Do not use it. It will be deleted in the next SDK.

◆ 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.