NAP
Public Member Functions | List of all members
DeletionQueue Class Referencefinal

#include <audio/utility/safeptr.h>

Public Member Functions

 DeletionQueue ()=default
 
 ~DeletionQueue ()
 
void enqueue (std::unique_ptr< SafeOwnerBase::Data > ownerData)
 
void clear ()
 

Description

The DeletionQueue holds the data that was previously owned by SafeOwner smart-pointers before they went out of scope. SafeOwner's destructor disposes it's owned data in the DeletionQueue and the DeletionQueue takes over ownership over this data. The DeletionQueue needs to be cleared regularly using the clear() method to free the heap of disposed data. When the DeletionQueue is cleared all SafePtrs that point to an object held by the queue will be cleared as well. By making use of the DeletionQueue in combination with SafeOwner and SafePtr the programmer can control or restrict the moment where objects are destructed and also choose the thread on which this will happen.

Constructor & Destructor Documentation

◆ DeletionQueue()

DeletionQueue ( )
default

◆ ~DeletionQueue()

The destructor enqueues all existing SafeOwners for deletion and clears the queue so all memory still held will be freed.

Member Function Documentation

◆ clear()

void clear ( )

Clears the DeletionQueue by destructing the objects it contains. It also clears all the SafePtrs that point to objects in the queue.

◆ enqueue()

void enqueue ( std::unique_ptr< SafeOwnerBase::Data ownerData)

This method is used by SafeOwner to dispose it's data when it goes out of scope. The disposed data will be kept by the DeletionQueue and will be destructed and freed on the next call of clear().