OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
owl::TMutex Class Reference

Mutual-exclusive semaphore. More...

#include <owl/thread.h>

Inheritance diagram for owl::TMutex:
owl::TSemaphore

Public Types

typedef TLock Lock
 For compatibility with old T-less typename.
 
- Public Types inherited from owl::TSemaphore
enum  { NoWait = 0 , NoLimit = INFINITE }
 
typedef HANDLE THandle
 

Public Member Functions

 TMutex (LPCTSTR name=nullptr, LPSECURITY_ATTRIBUTES sa=nullptr)
 Constructs a TMutex instance encapsulating a newly created named or unnamed mutex object.
 
 TMutex (const tstring &name, LPSECURITY_ATTRIBUTES sa=nullptr)
 String-aware overload.
 
 TMutex (LPCTSTR name, bool inherit, uint32 access=MUTEX_ALL_ACCESS)
 Open an existing mutex. Fails if not there.
 
 TMutex (const tstring &name, bool inherit, uint32 access=MUTEX_ALL_ACCESS)
 String-aware overlaod.
 
 TMutex (THandle handle)
 Constructs a Tmutex instance encapsulating a handle obtained by duplicating the specified handle.
 
bool IsShared ()
 If another mutex with the same name existed when this mutex was created, then another handle to the object exists and someone else may be using it too.
 
- Public Member Functions inherited from owl::TSemaphore
virtual ~TSemaphore ()
 
 operator THandle () const
 

Additional Inherited Members

- Protected Attributes inherited from owl::TSemaphore
THandle Handle
 Derived class must initialize.
 

Detailed Description

Mutual-exclusive semaphore.

TMutex provides a system-independent interface to critical sections in threads. With suitable underlying implementations the same code can be used under OS/2 and Windows NT. An object of type TMutex can be used in conjunction with objects of type TMutex::TLock (inherited from TSemaphore) to guarantee that only one thread can be executing any of the code sections protected by the lock at any given time. The differences between the classes TCriticalSection and TMutex are that a timeout can be specified when creating a Lock on a TMutex object, and that a TMutex object has a HANDLE which can be used outside the class. This mirrors the distinction made in Windows NT between a CRITICALSECTION and a Mutex. Under NT a TCriticalSection object is much faster than a TMutex object. Under operating systems that don't make this distinction a TCriticalSection object can use the same underlying implementation as a TMutex, losing the speed advantage that it has under NT.

Definition at line 121 of file thread.h.

Member Typedef Documentation

◆ Lock

For compatibility with old T-less typename.

Definition at line 129 of file thread.h.

Constructor & Destructor Documentation

◆ TMutex() [1/5]

owl::TMutex::TMutex ( LPCTSTR name = nullptr,
LPSECURITY_ATTRIBUTES sa = nullptr )
inline

Constructs a TMutex instance encapsulating a newly created named or unnamed mutex object.

The name parameter points to a null-terminated string specifying the name of the mutex object. The sa parameter points to a SECURITY_ATTRIBUTES structure that specifies the security attributes of the mutex object.

Note
The mutex object is not owned.

Definition at line 1040 of file thread.h.

References owl::TSemaphore::Handle.

◆ TMutex() [2/5]

owl::TMutex::TMutex ( const tstring & name,
LPSECURITY_ATTRIBUTES sa = nullptr )
inline

String-aware overload.

Definition at line 1051 of file thread.h.

References owl::TSemaphore::Handle.

◆ TMutex() [3/5]

owl::TMutex::TMutex ( LPCTSTR name,
bool inherit,
uint32 access = MUTEX_ALL_ACCESS )
inline

Open an existing mutex. Fails if not there.

This form of the constructor instantiates a TMutex object that encapsulates an existing named mutex object. The name parameter points to a null-terminated string that names the mutex to be opened.

Definition at line 1065 of file thread.h.

References owl::TSemaphore::Handle.

◆ TMutex() [4/5]

owl::TMutex::TMutex ( const tstring & name,
bool inherit,
uint32 access = MUTEX_ALL_ACCESS )
inline

String-aware overlaod.

Definition at line 1076 of file thread.h.

References owl::TSemaphore::Handle.

◆ TMutex() [5/5]

owl::TMutex::TMutex ( THandle handle)
inline

Constructs a Tmutex instance encapsulating a handle obtained by duplicating the specified handle.

The handle parameter is the source mutex object to be duplicated.

Note
The duplicated handle has the same access attributes as the source handle.

Definition at line 1090 of file thread.h.

References owl::TSemaphore::Handle.

Member Function Documentation

◆ IsShared()

bool owl::TMutex::IsShared ( )
inline

If another mutex with the same name existed when this mutex was created, then another handle to the object exists and someone else may be using it too.

Definition at line 1104 of file thread.h.


The documentation for this class was generated from the following files: