MADNESS
0.10.1
|
Deferred cleanup of shared_ptr's. More...
#include <deferred_cleanup.h>
Public Types | |
typedef std::shared_ptr< void > | void_ptr |
input pointer type More... | |
Public Member Functions | |
DeferredCleanup () | |
Construct a deferred deleter object. More... | |
template<typename objT > | |
void | add (const std::shared_ptr< objT > &obj) |
Adds item to cleanup list. More... | |
void | add (const void_ptr &obj) |
Adds item to cleanup list. More... | |
bool | destroy () const |
Get the current destruction mode mode. More... | |
void | destroy (bool mode) |
Set the destruction mode. More... | |
void | do_cleanup () |
Deletes/frees any pointers that are in the list. More... | |
Private Types | |
typedef std::list< void_ptr > | void_ptr_list |
Private Member Functions | |
DeferredCleanup (const DeferredCleanup &) | |
DeferredCleanup & | operator= (const DeferredCleanup &) |
Static Private Member Functions | |
static std::shared_ptr< DeferredCleanup > | get_deferred_cleanup (const World &w) |
Access deferred cleanup object of world. More... | |
Private Attributes | |
void_ptr_list | deferred_ |
List of pointers to cleanup. More... | |
bool | destroy_ |
RecursiveMutex | mutex_ |
Worldwide mutex. More... | |
Friends | |
template<typename objT > | |
void | deferred_cleanup (World &, const std::shared_ptr< objT > &, bool) |
Defer the cleanup of a shared pointer to the end of the next fence. More... | |
Deferred cleanup of shared_ptr's.
Holds dynamically allocated pointers until it is ready for cleanup.
DeferredDeleter
with a std::shared_ptr
. typedef std::shared_ptr<void> madness::detail::DeferredCleanup::void_ptr |
input pointer type
|
private |
|
private |
|
inline |
Construct a deferred deleter object.
|
inline |
Adds item
to cleanup list.
If destroy mode is true then the pointer is destroyed immediately. Otherwise it is stored until do_cleanup()
is called.
objT | The object pointer type |
obj | Object that is ready for destruction |
References add().
void madness::detail::DeferredCleanup::add | ( | const void_ptr & | obj | ) |
Adds item
to cleanup list.
If destroy mode is true then the pointer is destroyed immediately. Otherwise it is stored until do_cleanup()
is called.
obj | Object that is ready for destruction |
References deferred_, destroy_, and mutex_.
Referenced by add().
bool madness::detail::DeferredCleanup::destroy | ( | ) | const |
Get the current destruction mode mode.
References destroy_, madness::RecursiveMutex::lock(), mutex_, and madness::RecursiveMutex::unlock().
void madness::detail::DeferredCleanup::destroy | ( | bool | mode | ) |
Set the destruction mode.
mode | true for immediate destruction, false for deferred destruction. |
References destroy_, madness::RecursiveMutex::lock(), mutex_, and madness::RecursiveMutex::unlock().
void madness::detail::DeferredCleanup::do_cleanup | ( | ) |
Deletes/frees any pointers that are in the list.
References deferred_, madness::RecursiveMutex::lock(), mutex_, and madness::RecursiveMutex::unlock().
|
staticprivate |
Access deferred cleanup object of world.
w | The World object that holds the DeferredCleanup object |
w
. References w().
|
private |
|
friend |
Defer the cleanup of a shared pointer to the end of the next fence.
Call this function before destroying a shared pointer. If the shared pointer is the last reference to the object, or assume_p_is_unique
is true, it is placed in the deferred deletion list. Otherwise, nothing is done with the pointer.
|
private |
List of pointers to cleanup.
Referenced by add(), and do_cleanup().
|
private |
|
private |
Worldwide mutex.
Referenced by add(), destroy(), and do_cleanup().