Skip to content

Commit 7f700fb

Browse files
committed
fixed thread safe inject
1 parent 78a2cce commit 7f700fb

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

  • framework/global/thirdparty/kors_modularity/modularity

framework/global/thirdparty/kors_modularity/modularity/ioc.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ class ThreadSafeInjectBase : public InjectBase<I>
138138
public:
139139
using InjectBase<I>::InjectBase;
140140

141+
~ThreadSafeInjectBase()
142+
{
143+
std::shared_lock lock(m_mutex);
144+
InjectBase<I>::m_subscriber.unsubscribe();
145+
}
146+
141147
const std::shared_ptr<I>& get() const
142148
{
143149
{
@@ -164,7 +170,7 @@ class ThreadSafeInjectBase : public InjectBase<I>
164170
}
165171

166172
private:
167-
mutable std::shared_mutex m_mutex;
173+
static inline std::shared_mutex m_mutex;
168174
};
169175

170176
//! NOTE Global Inject

0 commit comments

Comments
 (0)