Replaces the default engine with a new instance.
- Parameters
-
| instance | New engine instance to use as default |
Transfers state from the old engine to the new one if possible.
- Warning
- This function uses move semantics. After calling this function, the engine instance passed as parameter will be left in a moved-from state and should not be used further. This is intentional to avoid resource duplication and ensure proper transfer of ownership. Users should be careful to not access the moved-from instance after calling this function.
This function is intended for advanced use cases where custom engine configuration is required beyond what the standard initialization functions provide.
Definition at line 73 of file Core.cpp.
74{
75 bool is_same_instance = false;
76
77 {
78 std::lock_guard<std::recursive_mutex> lock(internal::engine_mutex);
79 is_same_instance = (&
instance == internal::engine_ref.get());
80 if (internal::engine_ref && !is_same_instance && internal::engine_ref->is_running()) {
81 internal::engine_ref->Pause();
82 }
83 }
84
85 if (internal::engine_ref && !is_same_instance) {
86 internal::engine_ref->End();
87 }
88
89 if (!is_same_instance) {
90 std::lock_guard<std::recursive_mutex> lock(internal::engine_mutex);
91 internal::engine_ref = std::make_unique<Core::Engine>(std::move(
instance));
92 internal::initialized = true;
93 }
94}
References MayaFlux::internal::engine_mutex, MayaFlux::internal::engine_ref, MayaFlux::internal::initialized, and instance.