121 return (
value + align - 1U) & ~(align - 1U);
131 for (uint32_t i = 0; i < hdr->entry_count; ++i) {
132 if (hdr->entries[i].occupied
134 return &hdr->entries[i];
162 if (aligned_bump +
size > object_region_capacity) {
166 const uint32_t idx = hdr->entry_count;
167 auto& entry = hdr->entries[idx];
170 entry.offset = aligned_bump;
172 entry.occupied =
true;
201 const uint32_t idx = hdr->entry_count;
202 auto& entry = hdr->entries[idx];
205 entry.offset = UINT32_MAX;
206 entry.size = UINT32_MAX;
207 entry.occupied =
true;
225 template <
typename T>
228 return ::MayaFlux::Reflect::short_type_name<T>();
251 [[maybe_unused]]
static const bool live_exposure_registration = []()
noexcept {
264#define MF_LIVE_EXPOSE(key, ptr) \
266 if (::MayaFlux::internal::live_exposure_enabled()) \
267 ::MayaFlux::expose_live((key), (ptr)); \
281#define MF_LIVE_EXPOSE_AUTO(ptr) \
283 if (::MayaFlux::internal::live_exposure_enabled()) { \
284 using _MfT = typename std::remove_cvref_t<decltype(ptr)>::element_type; \
285 ::MayaFlux::expose_live_indexed( \
286 ::MayaFlux::internal::live_type_name<_MfT>(), (ptr)); \
300#define MF_LIVE_EXPOSE_NAMED(name, ptr) \
302 if (::MayaFlux::internal::live_exposure_enabled()) { \
303 ::MayaFlux::expose_live_indexed( \
304 std::string_view { (name) }, (ptr)); \
325template <
typename T,
typename... Args>
326std::shared_ptr<T>
make_live(
const char* key, Args&&... args)
330 static_cast<uint32_t
>(
sizeof(T)),
331 static_cast<uint32_t
>(
alignof(T)));
337 T* obj = ::new (mem) T(std::forward<Args>(args)...);
338 return std::shared_ptr<T>(obj, [](T*) { });
354bool expose_live(
const char* key,
const std::shared_ptr<T>& obj)
noexcept
435 return std::shared_ptr<T>(
static_cast<T*
>(
ptr), [](T*) { });
void enable_live_exposure() noexcept
Turns on exposure for the MF_LIVE_EXPOSE macros in the linked library.
constexpr std::size_t LIVE_ARENA_KEY_MAX
Maximum length of a live arena key, including null terminator.
uint32_t align_up(uint32_t value, uint32_t align) noexcept
Aligns value up to the next multiple of align.
constexpr std::size_t LIVE_ARENA_MAX_ENTRIES
Maximum number of objects that can be registered in the live arena.
constexpr std::string_view live_type_name() noexcept
Extracts the unqualified type name from a compiler-generated function signature.
uint32_t g_live_arena_bump
Byte offset of the bump pointer from the start of the object region.
constexpr std::size_t LIVE_ARENA_CAPACITY
Default capacity of the live arena in bytes.
bool live_exposure_enabled() noexcept
Reports whether live exposure has been enabled.
void live_format_key(char *buf, std::string_view name, uint32_t count) noexcept
Formats a live arena key as "TypeName_N" into buf.
LiveArenaHeader * live_arena_header() noexcept
Returns a pointer to the header block at the start of arena storage.
unsigned char * live_arena_object_region() noexcept
Returns a pointer to the object region (immediately after the header).
bool live_arena_expose(const char *key, std::shared_ptr< void > shared) noexcept
Registers an externally owned shared_ptr under key.
std::atomic< bool > g_live_exposure_enabled
Whether the MF_LIVE_EXPOSE macros publish objects to the arena.
LiveArenaEntry * live_arena_find(const char *key) noexcept
Locates an existing directory entry by key.
void * live_arena_alloc(const char *key, uint32_t size, uint32_t alignment) noexcept
Allocates size bytes from the arena with alignment.
unsigned char g_live_arena_storage[LIVE_ARENA_CAPACITY]
Raw backing storage for the live arena with external linkage.
std::shared_ptr< void > g_live_arena_shared_ptrs[LIVE_ARENA_MAX_ENTRIES]
Shared ownership table for objects registered via expose_live.
MAYAFLUX_API void * live_cast_impl(const char *key) noexcept
Internal implementation for live_cast.
bool expose_live(const char *key, const std::shared_ptr< T > &obj) noexcept
Exposes an existing shared_ptr-managed object to the live arena under key.
MAYAFLUX_API void live_arena_dump() noexcept
Dumps all live arena entries to stderr.
std::shared_ptr< T > live_cast(const char *key) noexcept
Retrieves a live-arena object by key as a shared_ptr<T>.
std::shared_ptr< T > make_live(const char *key, Args &&... args)
Constructs a T in-place inside the live arena and registers it under key.
bool expose_live_indexed(std::string_view prefix, const std::shared_ptr< T > &obj) noexcept
Exposes obj under the first free key of the form "prefix_N".
Main namespace for the Maya Flux audio engine.
Single directory entry mapping a string key to a location within the arena.