[K/N][New MM] Fix getting current thread data in thread suspension

This commit is contained in:
Ilya Matveev
2021-09-03 18:57:08 +07:00
committed by Space
parent bfc4ff6343
commit 474b2fc90e
@@ -22,7 +22,9 @@ bool isSuspendedOrNative(kotlin::mm::ThreadData& thread) noexcept {
template<typename F>
bool allThreads(F predicate) noexcept {
auto& threadRegistry = kotlin::mm::ThreadRegistry::Instance();
auto* currentThread = threadRegistry.CurrentThreadData();
auto* currentThread = (threadRegistry.IsCurrentThreadRegistered())
? threadRegistry.CurrentThreadData()
: nullptr;
kotlin::mm::ThreadRegistry::Iterable threads = kotlin::mm::ThreadRegistry::Instance().LockForIter();
for (auto& thread : threads) {
// Handle if suspension was initiated by the mutator thread.