Skip to content

Commit 892e75d

Browse files
rcorsiZaggy1024
authored andcommitted
LibCore: Fix ThreadedPromise issues found with ThreadSanitizer
1 parent ec73299 commit 892e75d

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

Libraries/LibCore/ThreadedPromise.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ class ThreadedPromise
6161

6262
bool has_completed()
6363
{
64-
Threading::MutexLocker locker { m_mutex };
6564
return m_has_completed;
6665
}
6766

@@ -183,7 +182,7 @@ class ThreadedPromise
183182
Function<ErrorOr<void>(ResultType&&)> m_resolution_handler;
184183
Function<void(ErrorType&&)> m_rejection_handler;
185184
Threading::Mutex m_mutex;
186-
bool m_has_completed;
185+
Atomic<bool> m_has_completed;
187186
};
188187

189188
}

Tests/LibCore/TestLibCorePromise.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ TEST_CASE(threaded_promise_resolved_later)
158158
{
159159
Core::EventLoop loop;
160160

161-
IGNORE_USE_IN_ESCAPING_LAMBDA bool unblock_thread = false;
161+
IGNORE_USE_IN_ESCAPING_LAMBDA Atomic<bool> unblock_thread = false;
162162
bool resolved = false;
163163
bool rejected = true;
164164
Optional<pthread_t> thread_id;

0 commit comments

Comments
 (0)