#include <MRSharedThreadSafeOwner.h>
Public Member Functions | |
| MRMESH_API | SharedThreadSafeOwner () |
| MRMESH_API | SharedThreadSafeOwner (const SharedThreadSafeOwner &) |
| MRMESH_API SharedThreadSafeOwner & | operator= (const SharedThreadSafeOwner &) |
| MRMESH_API | SharedThreadSafeOwner (SharedThreadSafeOwner &&b) noexcept |
| MRMESH_API SharedThreadSafeOwner & | operator= (SharedThreadSafeOwner &&b) noexcept |
| MRMESH_API | ~SharedThreadSafeOwner () |
| 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
| MRMESH_API MR::SharedThreadSafeOwner< T >::SharedThreadSafeOwner | ( | ) |
| MRMESH_API MR::SharedThreadSafeOwner< T >::SharedThreadSafeOwner | ( | const SharedThreadSafeOwner< T > & | ) |
|
noexcept |
| MRMESH_API MR::SharedThreadSafeOwner< T >::~SharedThreadSafeOwner | ( | ) |
|
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 SharedThreadSafeOwner & MR::SharedThreadSafeOwner< T >::operator= | ( | const SharedThreadSafeOwner< T > & | ) |
|
noexcept |
| MRMESH_API void MR::SharedThreadSafeOwner< T >::reset | ( | ) |
stops owning T-instance
| MRMESH_API void MR::SharedThreadSafeOwner< T >::update | ( | const std::function< void(T &)> & | updater | ) |