32#define BROOM_EXPORT __declspec(dllexport)
34#define BROOM_EXPORT __attribute__((visibility("default")))
37#define __BROOM_IMPL_CONSTRUCT_T(v, T, args) \
38 new (v) T(std::forward<Args>(args)...)
39#define __BROOM_IMPL_DESTRUCTOR_T(T) \
40 [](const void* pointer) { static_cast<const T*>(pointer)->~T(); }
41#define __BROOM_IMPL_ALLOCATE_T(T, RegisterFunction, AllocateFunction, args) \
45 if constexpr (!std::is_same_v<T, void>) { \
46 to_return = AllocateFunction(count * sizeof(T)); \
47 t_to_return = __BROOM_IMPL_CONSTRUCT_T(to_return, T, args); \
48 RegisterFunction(to_return, __BROOM_IMPL_DESTRUCTOR_T(T)); \
50 to_return = AllocateFunction(count); \
51 t_to_return = to_return; \
52 RegisterFunction(to_return, nullptr); \
81class GarbageCollector;
82extern thread_local GarbageCollector*
t_gc;
101#ifdef BROOM_FOR_TESTING
147 config.run_destructors_on_shutdown =
false;
178 config.support_sharing =
true;
210 config.support_sharing =
true;
211 config.run_destructors_on_shutdown =
false;
302template <
typename T,
typename...
Args>
460 void* precise_root_ref_;
565 __impl::ShareRaw(
static_cast<const void*
>(ptr),
how_many);
575 void dispose()
const { __impl::UnpinPointer(gc_, ptr_); }
585 : gc_(__impl::GetGarbageCollector()), ptr_(ptr) {}
590 GarbageCollector* gc_;
#define __BROOM_IMPL_ALLOCATE_T(T, RegisterFunction, AllocateFunction, args)
T * to_unsafe_ptr() const
BroomLifetimeAnchor(BroomSharingPointer< T > ptr)
BroomSharingPointer & operator=(const BroomSharingPointer &&other) noexcept=delete
T * to_unsafe_ptr() const
~BroomSharingPointer()=default
BroomSharingPointer()=delete
BroomSharingPointer & operator=(const BroomSharingPointer &other)=delete
static constexpr BroomSharingPointer make(T *ptr, uint32_t how_many)
BroomSharingPointer(const BroomSharingPointer &other)
virtual void Visit(Visitor *visitor) const =0
virtual void Visit(const void *pointer)=0
virtual ~Visitor()=default
void RegisterWithGc(const void *pointer, Destructor destructor)
void TurnOnGarbageCollection()
void * AllocateRaw(size_t size)
void TurnOffGarbageCollection()
void ShareRaw(const void *pointer, uint32_t how_many)
void UnpinPointer(GarbageCollector *gc, const void *pointer)
GarbageCollector * GetGarbageCollector()
std::add_pointer< void(const void *)>::type Destructor
thread_local GarbageCollector * t_gc
void unregister_external(const void *pointer)
void thread_init(broom_configuration config)
T * allocate(size_t count, Args &&... args)
std::queue< T, broom::deque< T > > queue
void register_external(const void *pointer, size_t size)
BroomSharingPointer< T > sharing_ptr
void force_slow_collection()
sharing_ptr< T > share(T *ptr, uint32_t count=1)
BroomDisableGcScope & operator=(BroomDisableGcScope &&other) noexcept=delete
BroomDisableGcScope(const BroomDisableGcScope &other)=delete
BroomDisableGcScope & operator=(const BroomDisableGcScope &other)=delete
BroomDisableGcScope(BroomDisableGcScope &&other)=delete
~BroomNoDestructorScope()
BroomNoDestructorScope & operator=(BroomNoDestructorScope &&other)=delete
BroomNoDestructorScope(const BroomNoDestructorScope &other)=delete
BroomNoDestructorScope(broom_configuration config={})
BroomNoDestructorScope & operator=(const BroomNoDestructorScope &other)=delete
BroomNoDestructorScope(BroomNoDestructorScope &&other)=delete
BroomScope(BroomScope &&other)=delete
BroomScope & operator=(BroomScope &&other)=delete
BroomScope(const BroomScope &other)=delete
BroomScope & operator=(const BroomScope &other)=delete
BroomScope(broom_configuration config={})
BroomSharingNoDestructorScope(BroomSharingNoDestructorScope &&other)=delete
~BroomSharingNoDestructorScope()
BroomSharingNoDestructorScope(broom_configuration config={})
BroomSharingNoDestructorScope(const BroomSharingNoDestructorScope &other)=delete
BroomSharingNoDestructorScope & operator=(const BroomSharingNoDestructorScope &other)=delete
BroomSharingNoDestructorScope & operator=(BroomSharingNoDestructorScope &&other)=delete
BroomSharingScope & operator=(BroomSharingScope &&other)=delete
BroomSharingScope(const BroomSharingScope &other)=delete
BroomSharingScope(BroomSharingScope &&other)=delete
BroomSharingScope(broom_configuration config={})
BroomSharingScope & operator=(const BroomSharingScope &other)=delete
bool run_destructors_on_shutdown