SuperTuxKart
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
CanBeDeleted Class Reference

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>

Inheritance diagram for CanBeDeleted:
Inheritance graph
[legend]

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
 

Detailed Description

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.

Member Function Documentation

◆ waitForReadyToDeleted()

bool CanBeDeleted::waitForReadyToDeleted ( float  waiting_time)
inline

Waits at most t seconds for this class to be ready to be deleted.

Returns
true if the class is ready, false in case of a time out.

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