#include <MRSharedThreadSafeOwner.h>
Public Member Functions | |
| MRMESH_API void | reset () |
| stops owning T-instance | |
| const T * | get () |
| returns the currently owned instance, the pointer becomes invalid after reset() or update() | |
| std::shared_ptr< const T > | getPtr () |
| returns the currently owned instance | |
| MRMESH_API const T & | getOrCreate (const std::function< T()> &creator) |
| MRMESH_API void | update (const std::function< void(T &)> &updater) |
| MRMESH_API size_t | heapBytes () const |
| returns the amount of memory this object occupies on heap | |
A group of these objects owns collectively one T-instance, allowing access to stored instance from parallel threads; if one object updates its T-instance, then it makes a copy of T-instance first and become the only object in new group
|
inlinenodiscard |
| MRMESH_API const T & MR::SharedThreadSafeOwner< T >::getOrCreate | ( | const std::function< T()> & | creator | ) |
returns the currently owned instance (if any), otherwise calls (creator) to create new owned instance, which is returned; if many threads call this simultaneously, then they can collectively participate in the construction
|
inlinenodiscard |
returns the currently owned instance
|
nodiscard |
returns the amount of memory this object occupies on heap
| MRMESH_API void MR::SharedThreadSafeOwner< T >::reset | ( | ) |
stops owning T-instance
| MRMESH_API void MR::SharedThreadSafeOwner< T >::update | ( | const std::function< void(T &)> & | updater | ) |