Broom 1.0.0
A thread-local C++ Garbage Collector
Loading...
Searching...
No Matches
Classes | Namespaces | Macros | Typedefs | Functions
broom.h File Reference
#include <assert.h>
#include <stddef.h>
#include <memory>
#include <type_traits>
Include dependency graph for broom.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  broom_configuration_s
 
struct  broom::BroomScope
 
struct  broom::BroomNoDestructorScope
 
struct  broom::BroomSharingScope
 
struct  broom::BroomSharingNoDestructorScope
 
struct  broom::BroomDisableGcScope
 
class  broom::Visitor
 
class  broom::BroomValue
 
class  broom::BroomSharingPointer< T >
 
class  broom::BroomLifetimeAnchor< T >
 

Namespaces

namespace  broom
 
namespace  broom::__impl
 

Macros

#define BROOM_EXPORT   __attribute__((visibility("default")))
 
#define __BROOM_IMPL_CONSTRUCT_T(v, T, args)    new (v) T(std::forward<Args>(args)...)
 
#define __BROOM_IMPL_DESTRUCTOR_T(T)    [](const void* pointer) { static_cast<const T*>(pointer)->~T(); }
 
#define __BROOM_IMPL_ALLOCATE_T(T, RegisterFunction, AllocateFunction, args)
 

Typedefs

typedef struct broom_configuration_s broom_configuration
 
using broom::scope = BroomScope
 
using broom::sharing_scope = BroomSharingScope
 
using broom::no_destructor_scope = BroomNoDestructorScope
 
using broom::sharing_no_destructor_scope = BroomSharingNoDestructorScope
 
using broom::Destructor = std::add_pointer< void(const void *)>::type
 
using broom::disable_gc_scope = BroomDisableGcScope
 
using broom::gc_visitor = Visitor
 
using broom::gc_root = BroomValue
 
template<typename T >
using broom::sharing_ptr = BroomSharingPointer< T >
 
template<typename T >
using broom::lifetime_anchor = BroomLifetimeAnchor< T >
 

Functions

void broom::thread_init (broom_configuration config)
 
void broom::thread_teardown ()
 
voidbroom::__impl::AllocateRaw (size_t size)
 
void broom::__impl::RegisterWithGc (const void *pointer, Destructor destructor)
 
void broom::__impl::ShareRaw (const void *pointer, uint32_t how_many)
 
void broom::__impl::UnpinPointer (GarbageCollector *gc, const void *pointer)
 
void broom::__impl::TurnOnGarbageCollection ()
 
void broom::__impl::TurnOffGarbageCollection ()
 
GarbageCollectorbroom::__impl::GetGarbageCollector ()
 
template<typename T , typename... Args>
T * broom::allocate (size_t count, Args &&... args)
 
void broom::force_collection ()
 
void broom::force_slow_collection ()
 
void broom::register_external (const void *pointer, size_t size)
 
void broom::unregister_external (const void *pointer)
 
template<typename T >
sharing_ptr< T > broom::share (T *ptr, uint32_t count=1)
 

Macro Definition Documentation

◆ __BROOM_IMPL_ALLOCATE_T

#define __BROOM_IMPL_ALLOCATE_T (   T,
  RegisterFunction,
  AllocateFunction,
  args 
)
Value:
{ \
T* t_to_return; \
void* to_return; \
if constexpr (!std::is_same_v<T, void>) { \
to_return = AllocateFunction(count * sizeof(T)); \
t_to_return = __BROOM_IMPL_CONSTRUCT_T(to_return, T, args); \
RegisterFunction(to_return, __BROOM_IMPL_DESTRUCTOR_T(T)); \
} else { \
to_return = AllocateFunction(count); \
t_to_return = to_return; \
RegisterFunction(to_return, nullptr); \
} \
return t_to_return; \
}
#define __BROOM_IMPL_CONSTRUCT_T(v, T, args)
Definition broom.h:37
#define __BROOM_IMPL_DESTRUCTOR_T(T)
Definition broom.h:39

Definition at line 41 of file broom.h.

◆ __BROOM_IMPL_CONSTRUCT_T

#define __BROOM_IMPL_CONSTRUCT_T (   v,
  T,
  args 
)     new (v) T(std::forward<Args>(args)...)

Definition at line 37 of file broom.h.

◆ __BROOM_IMPL_DESTRUCTOR_T

#define __BROOM_IMPL_DESTRUCTOR_T (   T)     [](const void* pointer) { static_cast<const T*>(pointer)->~T(); }

Definition at line 39 of file broom.h.

◆ BROOM_EXPORT

#define BROOM_EXPORT   __attribute__((visibility("default")))

Definition at line 34 of file broom.h.

Typedef Documentation

◆ broom_configuration

A type alias for broom_configuration_s.

Definition at line 78 of file broom.h.