wxWidgets: wxMutexLocker Class Reference

| Version: 3.0.4

- Main Page
- Related Pages
- Categories
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | List of all members
wxMutexLocker Class Reference
Class List by Category » Threading

`#include <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
Category: Threading

See also
  wxMutex, wxCriticalSectionLocker

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

## Constructor & Destructor Documentation

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 | ( |  | ) |

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

## Member Function Documentation

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

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