MCPcopy Create free account
hub / github.com/baidu/babylon / create_singleton

Method create_singleton

src/babylon/application_context.cpp:163–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161}
162
163void ApplicationContext::ComponentHolder::create_singleton(
164 ApplicationContext& context) noexcept {
165 ::std::lock_guard<std::recursive_mutex> lock(*_mutex);
166 if (_singleton_state == ComponentHolder::SingletonState::INITIALIZING) {
167 BABYLON_LOG(WARNING)
168 << "initialize failed for recursive dependent component of type "
169 << _type_id->type_id;
170 return;
171 }
172 if (_singleton_state == ComponentHolder::SingletonState::UNINITIALIZED) {
173 _singleton_state = ComponentHolder::SingletonState::INITIALIZING;
174 _singleton = create(context);
175 _sequence = next_sequence();
176 atomic_singleton_state().store(ComponentHolder::SingletonState::INITIALIZED,
177 ::std::memory_order_release);
178 }
179}
180
181#pragma GCC diagnostic push
182#pragma GCC diagnostic ignored "-Wpragmas"

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected