STLdoc
STLdocumentation
|
A non-reentrant mutex which is explicitly aware of the Concurrency Runtime. More...
#include <concrt.h>
Classes | |
class | scoped_lock |
An exception safe RAII wrapper for a critical_section object. More... | |
Public Types | |
typedef critical_section & | native_handle_type |
A reference to a critical_section object. More... | |
Public Member Functions | |
_CRTIMP | critical_section () |
Constructs a new critical section. More... | |
_CRTIMP | ~critical_section () |
Destroys a critical section. More... | |
_CRTIMP void | lock () |
Acquires this critical section. More... | |
_CRTIMP bool | try_lock () |
Tries to acquire the lock without blocking. More... | |
_CRTIMP bool | try_lock_for (unsigned int _Timeout) |
Tries to acquire the lock without blocking for a specific number of milliseconds. More... | |
_CRTIMP void | unlock () |
Unlocks the critical section. More... | |
_CRTIMP native_handle_type | native_handle () |
Returns a platform specific native handle, if one exists. More... | |
void | _Flush_current_owner () |
Guarantees that if any context holds the lock at the time the method is called, that context has released the lock before this method returns. More... | |
bool | _Acquire_lock (void *_PLockingNode, bool _FHasExternalNode) |
Acquires this critical section given a specific node to lock. More... | |
Private Member Functions | |
void | _Switch_to_active (void *_PLockingNode) |
The node allocated on the stack never really owns the lock because it would go out of scope and the insides would not be visible in unlock() where it could potentially need to unblock the next in the queue. Instead, its state is transferred to the internal node which is used as a scratch node. More... | |
critical_section (const critical_section &) | |
Hide copy constructor for a critical section More... | |
critical_section & | operator= (const critical_section &) |
Hide assignment operator for a critical section More... | |
Private Attributes | |
_CONCRT_BUFFER | _M_activeNode [(4 *sizeof(void *)+2 *sizeof(unsigned int)+sizeof(_CONCRT_BUFFER)-1)/sizeof(_CONCRT_BUFFER)] |
void *volatile | _M_pHead |
void *volatile | _M_pTail |
A non-reentrant mutex which is explicitly aware of the Concurrency Runtime.
For more information, see Synchronization Data Structures.
A reference to a critical_section
object.
_CRTIMP Concurrency::critical_section::critical_section | ( | ) |
Constructs a new critical section.
_CRTIMP Concurrency::critical_section::~critical_section | ( | ) |
Destroys a critical section.
It is expected that the lock is no longer held when the destructor runs. Allowing the critical section to destruct with the lock still held results in undefined behavior.
|
private |
Hide copy constructor for a critical section
Acquires this critical section given a specific node to lock.
_PLockingNode | The node that needs to own the lock. |
_FHasExternalNode | An indication if the node being locked is external to the critical_section. |
If the lock is already held by the calling context, an .improper_lock exception will be thrown.
void Concurrency::critical_section::_Flush_current_owner | ( | ) |
Guarantees that if any context holds the lock at the time the method is called, that context has released the lock before this method returns.
If no context holds the lock at the instant this method is called, it returns instantly.
The node allocated on the stack never really owns the lock because it would go out of scope and the insides would not be visible in unlock() where it could potentially need to unblock the next in the queue. Instead, its state is transferred to the internal node which is used as a scratch node.
_PLockingNode | The node that needs to own the lock. |
Acquires this critical section.
It is often safer to utilize the scoped_lock construct to acquire and release a critical_section
object in an exception safe way.
If the lock is already held by the calling context, an improper_lock exception will be thrown.
_CRTIMP native_handle_type Concurrency::critical_section::native_handle | ( | ) |
Returns a platform specific native handle, if one exists.
A critical_section
object is not associated with a platform specific native handle for the Windows operating system. The method simply returns a reference to the object itself.
|
private |
Hide assignment operator for a critical section
Tries to acquire the lock without blocking.
true
; otherwise, the value false
. Tries to acquire the lock without blocking for a specific number of milliseconds.
_Timeout | The number of milliseconds to wait before timing out. |
true
; otherwise, the value false
. Unlocks the critical section.
|
private |
|
private |
|
private |