The Battle for Wesnoth  1.19.7+dev
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
unit::recursion_guard Class Reference

Helper similar to std::unique_lock for detecting when calculations such as abilities have entered infinite recursion. More...

Public Member Functions

 recursion_guard ()
 Construct an empty instance, only useful for extending the lifetime of a recursion_guard returned from unit.update_variables_recursion() by std::moving it to an instance declared in a larger scope. More...
 
 operator bool () const
 Returns true if a level of recursion was available at the time when update_variables_recursion() created this object. More...
 
 recursion_guard (recursion_guard &&other)
 
 recursion_guard (const recursion_guard &other)=delete
 
recursion_guardoperator= (recursion_guard &&)
 
recursion_guardoperator= (const recursion_guard &)=delete
 
 ~recursion_guard ()
 

Private Member Functions

 recursion_guard (const unit &u, const config &ability)
 Only expected to be called in update_variables_recursion(), which handles some of the checks. More...
 

Private Attributes

std::shared_ptr< const unitparent
 

Friends

class unit
 

Detailed Description

Helper similar to std::unique_lock for detecting when calculations such as abilities have entered infinite recursion.

This assumes that there's only a single thread accessing the unit, it's a lightweight increment/decrement counter rather than a mutex.

Definition at line 1882 of file unit.hpp.


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