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

◆ cleanup_engine()

void MayaFlux::internal::cleanup_engine ( )

Definition at line 27 of file Core.cpp.

28 {
29 if (cleaning_up) {
30 return;
31 }
32
33 if (ending.exchange(true, std::memory_order_acq_rel)) {
34 while (ending.load(std::memory_order_acquire)) {
35 std::this_thread::yield();
36 }
37 return;
38 }
39
40 cleaning_up = true;
41
42 if (std::unique_ptr<Core::Engine> engine { engine_ptr.load(std::memory_order_acquire) }) {
43 if (initialized.load(std::memory_order_acquire)) {
44 engine->End();
45 Journal::Archivist::shutdown();
46 }
48 initialized.store(false, std::memory_order_release);
49 engine_ptr.store(nullptr, std::memory_order_release);
50 }
51
52 cleaning_up = false;
53 ending.store(false, std::memory_order_release);
54 }
thread_local bool cleaning_up
Definition Core.cpp:25
std::atomic< bool > ending
Definition Core.cpp:23
std::atomic< bool > initialized
Definition Core.cpp:21
void cleanup_persistent_store()
Definition Persist.hpp:14
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 cleaning_up, cleanup_persistent_store(), ending, engine_ptr, initialized, and MayaFlux::Journal::Archivist::shutdown().

Referenced by MayaFlux::End(), and get_or_create_engine().

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