SuperTuxKart
|
A simple class that a adds a function to wait with a timeout for a class to be ready to be deleted. More...
#include <can_be_deleted.hpp>
Public Member Functions | |
CanBeDeleted () | |
Set this instance to be not ready to be deleted. | |
void | setCanBeDeleted () |
Sets this instance to be ready to be deleted. | |
void | resetCanBeDeleted () |
bool | canBeDeletedNow () |
bool | waitForReadyToDeleted (float waiting_time) |
Waits at most t seconds for this class to be ready to be deleted. | |
Private Attributes | |
std::atomic_bool | m_can_be_deleted |
A simple class that a adds a function to wait with a timeout for a class to be ready to be deleted.
It is used for objects with their own threads (e.g. RequestManager) to make sure they can be deleted. For example, the RequestManager might be executing a download request. So we have to signal libcurl to abort the download request, then potentially handle a high priority sign-out request before the thread can be deleted. With this object the main thread can wait for a given amount of time (in case that of a bad internet hickup) before deleting the RequestManager.
|
inline |
Waits at most t seconds for this class to be ready to be deleted.