File tree Expand file tree Collapse file tree
framework/global/thirdparty/kors_modularity/modularity Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -118,7 +118,7 @@ class InjectBase
118118 {
119119 static std::string_view module = " " ;
120120 m_i = ioc->template resolve <I>(module );
121- if (m_i) {
121+ if (m_i && m_isSubscribe ) {
122122 m_subscriber.onChanged = [this ](const std::shared_ptr<I>& p) {
123123 m_i = p;
124124 };
@@ -129,6 +129,7 @@ class InjectBase
129129 const ContextPtr m_ctx;
130130 const Contextable* m_inj = nullptr ;
131131 mutable std::shared_ptr<I> m_i = nullptr ;
132+ mutable bool m_isSubscribe = true ;
132133 mutable Subscriber<I> m_subscriber;
133134};
134135
@@ -148,6 +149,9 @@ class ThreadSafeInjectBase : public InjectBase<I>
148149 }
149150
150151 std::unique_lock lock (m_mutex);
152+ // ! NOTE Subscribing to changes is not thread-safe,
153+ // so it is disabled for ThreadSafeInject.
154+ InjectBase<I>::m_isSubscribe = false ;
151155 return InjectBase<I>::get ();
152156 }
153157
You can’t perform that action at this time.
0 commit comments