AAO DRAMA/DRAMA2 C++ Interface
DRAMA C++11 and later interface
Public Member Functions | List of all members
drama::ScopeGuardAtomic< AT, T > Class Template Reference

Detailed Description

template<typename AT, typename T>
class drama::ScopeGuardAtomic< AT, T >

This class implements a simple scope guard class with an std::atomic based type as the underlying type.

It will allow an item to be set to a particular value from construction and then reset when destroyed.

This class is similar to many C++ scope guard cases (e.g. std::unique_ptr) but intended for simple cases where say a value of a class is to be set from the construction point onwards and then reset when the destructor is run. Unlike the ScopeGuard class, by using a std::atomic<> based item as the item we guard, the guarded value is thread safe.

#include "util.hh"

Public Member Functions

 ScopeGuardAtomic (AT &item, const T executionVal)
 Construct a ScopeGuardAtomic for the specified item.
 
 ScopeGuardAtomic (AT &item, const T executionVal, const T exitVal)
 Construct a ScopeGuardAtomic for the specified item.
 
 ~ScopeGuardAtomic ()
 Destroy the ScopeGuardAtomic item, restoring its value to the specified exit value.
 

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