MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
LiveArena.cpp
Go to the documentation of this file.
2
3namespace MayaFlux {
4
5namespace internal {
6
7 alignas(std::max_align_t) unsigned char g_live_arena_storage[LIVE_ARENA_CAPACITY] {};
8 uint32_t g_live_arena_bump {};
10
11} // namespace internal
12
13MAYAFLUX_API void* live_cast_impl(const char* key) noexcept
14{
15 auto* hdr = internal::live_arena_header();
16 for (uint32_t i = 0; i < hdr->entry_count; ++i) {
17 auto& entry = hdr->entries[i];
18 if (!entry.occupied) {
19 continue;
20 }
21 if (std::strncmp(entry.key, key, internal::LIVE_ARENA_KEY_MAX) != 0) {
22 continue;
23 }
24 if (entry.offset == UINT32_MAX) {
26 }
27 return internal::live_arena_object_region() + entry.offset;
28 }
29 return nullptr;
30}
31
32MAYAFLUX_API void live_arena_dump() noexcept
33{
34 auto* hdr = internal::live_arena_header();
35 for (uint32_t i = 0; i < hdr->entry_count; ++i) {
36 auto& entry = hdr->entries[i];
37 fprintf(stderr, "[LiveArena] %u: key=\"%s\" occupied=%d offset=%u\n",
38 i, entry.key, (int)entry.occupied, entry.offset);
39 }
40 fprintf(stderr, "[LiveArena] entry_count=%u bump=%u\n",
41 hdr->entry_count, internal::g_live_arena_bump);
42}
43
44} // namespace MayaFlux
constexpr std::size_t LIVE_ARENA_KEY_MAX
Maximum length of a live arena key, including null terminator.
Definition LiveArena.hpp:21
constexpr std::size_t LIVE_ARENA_MAX_ENTRIES
Maximum number of objects that can be registered in the live arena.
Definition LiveArena.hpp:16
uint32_t g_live_arena_bump
Byte offset of the bump pointer from the start of the object region.
Definition LiveArena.cpp:8
constexpr std::size_t LIVE_ARENA_CAPACITY
Default capacity of the live arena in bytes.
Definition LiveArena.hpp:26
LiveArenaHeader * live_arena_header() noexcept
Returns a pointer to the header block at the start of arena storage.
Definition LiveArena.hpp:83
unsigned char * live_arena_object_region() noexcept
Returns a pointer to the object region (immediately after the header).
Definition LiveArena.hpp:91
unsigned char g_live_arena_storage[LIVE_ARENA_CAPACITY]
Raw backing storage for the live arena with external linkage.
Definition LiveArena.cpp:7
std::shared_ptr< void > g_live_arena_shared_ptrs[LIVE_ARENA_MAX_ENTRIES]
Shared ownership table for objects registered via expose_live.
Definition LiveArena.cpp:9
MAYAFLUX_API void * live_cast_impl(const char *key) noexcept
Internal implementation for live_cast.
Definition LiveArena.cpp:13
MAYAFLUX_API void live_arena_dump() noexcept
Dumps all live arena entries to stderr.
Definition LiveArena.cpp:32
Main namespace for the Maya Flux audio engine.
Definition Runtime.cpp:12