wxWidgets: wxMutexLocker Class Reference

| Version: 3.1.5

Loading...
Searching...
No Matches
Public Member Functions | List of all members
wxMutexLocker Class Reference
Class List by Category » Threading

`#include </cygdrive/c/Users/Hamis/Cygwin-packaging/wxWidgets3.1/wxWidgets3.1-3.1.5-4.x86_64/src/wxWidgets-3.1.5/interface/wx/thread.h>`

## Detailed Description

This is a small helper class to be used with wxMutex objects.

A wxMutexLocker acquires a mutex lock in the constructor and releases (or unlocks) the mutex in the destructor making it much more difficult to forget to release a mutex (which, in general, will promptly lead to serious problems). See wxMutex for an example of wxMutexLocker usage.

##

Library: wxBase

<>< =''>:</>&;&;< =''>\ </></>

See also
  wxMutex, wxCriticalSectionLocker

## Public Member Functions
| wxMutexLocker (wxMutex &mutex)
| Constructs a wxMutexLocker object associated with mutex and locks it.
| ~wxMutexLocker ()
| Destructor releases the mutex if it was successfully acquired in the ctor.
bool | IsOk () const
| Returns true if mutex was acquired in the constructor, false otherwise.

## Constructor & Destructor Documentation

## ◆ wxMutexLocker()

wxMutexLocker::wxMutexLocker | ( | wxMutex & | mutex | ) |

Constructs a wxMutexLocker object associated with mutex and locks it.

Call IsOk() to check if the mutex was successfully locked.

## ◆ ~wxMutexLocker()

wxMutexLocker::~wxMutexLocker | ( |  | ) |

Destructor releases the mutex if it was successfully acquired in the ctor.

## Member Function Documentation

## ◆ IsOk()

bool wxMutexLocker::IsOk | ( |  | ) | const

Returns true if mutex was acquired in the constructor, false otherwise.