Repository navigation
life_token
A class that controls marking callbacks as "dead", and waiting for their completion if they are being invoked at the moment of life_token destruction. Used for proper disconnecting from signals in wigwag library.
You can also use it in your code for any callback-like entities (e.g. listeners or setTimer/setTimeout callbacks).
Defined in wigwag/life_token.hpp
class life_token
{
public:
class checker
{
public:
checker(const life_token& token);
};
class execution_guard
{
public:
execution_guard(const life_token& token);
execution_guard(const life_token::checker& checker);
~execution_guard();
bool is_alive() const;
};
public:
life_token();
life_token(life_token&& other);
~life_token();
void release();
life_token(const life_token&) = delete;
life_token& operator = (const life_token&) = delete;
};class life_token::checker
{
public:
checker(const life_token& token);
};The checker object refers to a certain life_token and allows a programmer to lock it for execution via execution_guard.
class life_token::execution_guard
{
public:
execution_guard(const life_token& token);
execution_guard(const life_token::checker& checker);
~execution_guard();
bool is_alive() const;
};The execution_guard object locks a life_token object for execution time and allows to check if the life_token is still alive (that is, the callback may be accessed).
life_token();Creates a life_token object.
life_token(life_token&& other);Moves a life_token object.
~life_token();Releases a life_token object if it hasn't been released before.
If a life_token object was locked via execution_guard, the destructor blocks until all the execution_guards are released.
life_token(const life_token&) = delete;The copy constructor is prohibited
void release();Releases a life_token object if it hasn't been released before.
If a life_token object was locked via execution_guard, the release method blocks until all the execution_guards are released.
life_token& operator = (const life_token&) = delete;The assignment operator is prohibited