|
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 | |
Public Member Functions | |
| DeferredCleanup () | |
| Construct a deferred deleter object. | |
| template<typename objT > | |
| void | add (const std::shared_ptr< objT > &obj) |
Adds item to cleanup list. | |
| void | add (const void_ptr &obj) |
Adds item to cleanup list. | |
| bool | destroy () const |
| Get the current destruction mode mode. | |
| void | destroy (bool mode) |
| Set the destruction mode. | |
| void | do_cleanup () |
| Deletes/frees any pointers that are in the list. | |
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. | |
Private Attributes | |
| void_ptr_list | deferred_ |
| List of pointers to cleanup. | |
| bool | destroy_ |
| RecursiveMutex | mutex_ |
| Worldwide mutex. | |
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. | |
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(), and madness::nonlinear_vector_solver().
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_, mutex_, and madness::nonlinear_vector_solver().
Referenced by add().
| bool madness::detail::DeferredCleanup::destroy | ( | ) | const |
Get the current destruction mode mode.
References destroy_, madness::RecursiveMutex::lock(), mutex_, madness::nonlinear_vector_solver(), and madness::RecursiveMutex::unlock().
Set the destruction mode.
| mode | true for immediate destruction, false for deferred destruction. |
References destroy_, madness::RecursiveMutex::lock(), mutex_, madness::nonlinear_vector_solver(), 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_, madness::nonlinear_vector_solver(), 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(), destroy(), and do_cleanup().