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

◆ get_or_create_engine()

Core::Engine & MayaFlux::internal::get_or_create_engine ( )

Definition at line 56 of file Core.cpp.

57 {
58 Core::Engine* engine = engine_ptr.load(std::memory_order_acquire);
59 if (engine) {
60 return *engine;
61 }
62
63 auto candidate = std::make_unique<Core::Engine>();
64 Core::Engine* expected = nullptr;
65 if (engine_ptr.compare_exchange_strong(expected, candidate.get(),
66 std::memory_order_acq_rel, std::memory_order_acquire)) {
67 engine = candidate.release();
68 if (!atexit_registered.exchange(true, std::memory_order_acq_rel)) {
69 std::atexit(cleanup_engine);
70 }
71 terminating.store(false, std::memory_order_release);
72 initialized.store(true, std::memory_order_release);
73 } else {
74 engine = expected;
75 }
76 return *engine;
77 }
Central lifecycle manager and component orchestrator for the MayaFlux processing system.
Definition Engine.hpp:80
std::atomic< Core::Engine * > engine_ptr
The engine is published through a raw atomic pointer and is freed only after End() has joined every t...
Definition Core.cpp:20

References atexit_registered, cleanup_engine(), engine_ptr, initialized, and terminating.

Referenced by MayaFlux::get_context(), MayaFlux::Init(), MayaFlux::Init(), and MayaFlux::Init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: