Repository navigation
token
A RAII class for managing generic resource ownership. Used for holding signal/listenable connections in wigwag library.
Here is the tutorial section.
Defined in wigwag/token.hpp
class token
{
public:
token(token&& other);
~token();
token& operator = (token&& other);
token(const token&) = delete;
token& operator = (const token&) = delete;
void reset();
};token(token&& other);Just an ordinary move constructor. Nothing special.
token(const token&) = delete;The copy constructor is prohibited.
~token();Resets a token object if it hasn't been reset before.
Releases the associated resource (e.g. signal connection).
void reset();Resets a token object if it hasn't been reset before.
Releases the associated resource (e.g. signal connection).
Thread safety: This is NOT a thread-safe method. If you assign to a token from one thread, and reset it from another, you should guard the token with a mutex or something else.
(1)
token& operator = (const token&) = delete;
(2)
token& operator = (token&&);(1)
The copy assignment operator is prohibited
(2)
The move assignment operator resets the token object, and then moves the resource ownership from another one
Thread safety: (2) is NOT a thread-safe method. If you assign to a token from different threads, you should guard the token with a mutex or something else.