MeshLib C++ Docs
Loading...
Searching...
No Matches
MRSharedThreadSafeOwner.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMeshFwd.h"
4#include "MRPch/MRBindingMacros.h"
5#include <functional>
6#include <memory>
7
8namespace MR
9{
10
13
17template<typename T>
19{
20public:
27
30
32 [[nodiscard]] const T* get() { return obj_.get(); }
33
35 [[nodiscard]] std::shared_ptr<const T> getPtr() { return obj_; }
36
40 MRMESH_API const T & getOrCreate( const std::function<T()> & creator );
41
44 MRMESH_API void update( const std::function<void(T&)> & updater );
45
47 [[nodiscard]] MRMESH_API size_t heapBytes() const;
48
49private:
51 std::shared_ptr<T> obj_;
52
54 std::shared_ptr<TbbTaskArenaAndGroup> construction_;
55};
56
58
59}
#define MRMESH_API
Definition MRMeshFwd.h:80
const T * get()
returns the currently owned instance, the pointer becomes invalid after reset() or update()
Definition MRSharedThreadSafeOwner.h:32
SharedThreadSafeOwner(SharedThreadSafeOwner &&b) noexcept
void reset()
stops owning T-instance
std::shared_ptr< const T > getPtr()
returns the currently owned instance
Definition MRSharedThreadSafeOwner.h:35
SharedThreadSafeOwner(const SharedThreadSafeOwner &)
void update(const std::function< void(T &)> &updater)
size_t heapBytes() const
returns the amount of memory this object occupies on heap
const T & getOrCreate(const std::function< T()> &creator)
std::array< Vector3f, 3 > MR_BIND_IGNORE
Definition MRMeshBuilderTypes.h:13
only for bindings generation
Definition MRCameraOrientationPlugin.h:8