Wt: Wt::WApplication::UpdateLock Class Reference

Wt 4.10.4

Loading...
Searching...
No Matches
Public Member Functions | List of all members
Wt::WApplication::UpdateLock Class Reference

A RAII lock for manipulating and updating the application and its widgets outside of the event loop. More...

`#include <WApplication.h>`

## Public Member Functions
| UpdateLock (WApplication *app)
| Creates and locks the given application.
| operator bool () const
| Tests whether the update lock was succesfully taken.
| ~UpdateLock ()
| Releases the lock.

## Detailed Description

A RAII lock for manipulating and updating the application and its widgets outside of the event loop.

You can use this lock to manipulate widgets outside of the event loop. Inside the event loop (including events posted using WServer::post()), this lock is already held by the library itself.

The lock is recursive, so trying to take a lock, while already holding a lock, will not block.

## Constructor & Destructor Documentation

## ◆ UpdateLock()

Wt::WApplication::UpdateLock::UpdateLock | ( | WApplication * | app | ) |

Creates and locks the given application.

The lock guarantees exclusive access to modify the application's state.

You should also consider WServer::post() for lock-free communication between different application sessions.

As soon as the library decides to destroy the application, the lock will no longer succeed in taking the application lock. You can need to detect this by checking that after the lock is taken, the lock is taken:

WApplication::UpdateLock lock(app);
if (lock) {
// exclusive access to app state
}
Wt::WApplication::UpdateLock
A RAII lock for manipulating and updating the application and its widgets outside of the event loop.
Definition WApplication.h:1340

## Member Function Documentation

## ◆ operator bool()

Wt::WApplication::UpdateLock::operator bool | ( |  | ) | const
| explicit

Tests whether the update lock was succesfully taken.

This may return `false` when the library has already decided to destroy the session (but before your application finalizer/destructor has run to notify helper threads that the application is destroyed).