MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ make_live()

template<typename T , typename... Args>
std::shared_ptr< T > MayaFlux::make_live ( const char *  key,
Args &&...  args 
)

Constructs a T in-place inside the live arena and registers it under key.

The returned shared_ptr is stable for the process lifetime and participates in normal shared_ptr ref-counting. The arena owns the underlying storage; the shared_ptr uses a no-op deleter so the arena remains the sole allocator.

Reachable from JIT'd code immediately via live_cast<T>(key).

Template Parameters
TType to construct.
Parameters
keyNull-terminated string used to locate the object from the JIT. Must be unique within the arena.
argsArguments forwarded to T's constructor.
Returns
shared_ptr to the constructed object, or nullptr if the arena is full or key is already registered.

Definition at line 321 of file LiveArena.hpp.

322{
323 void* mem = internal::live_arena_alloc(
324 key,
325 static_cast<uint32_t>(sizeof(T)),
326 static_cast<uint32_t>(alignof(T)));
327
328 if (!mem) {
329 return nullptr;
330 }
331
332 T* obj = ::new (mem) T(std::forward<Args>(args)...);
333 return std::shared_ptr<T>(obj, [](T*) { });
334}

References MayaFlux::internal::live_arena_alloc().

+ Here is the call graph for this function: