Skip to content

Commit 59ab103

Browse files
committed
perf: avoid taking mutex on already-resolved promises
1 parent 61e26c0 commit 59ab103

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Diff for: src/runtime/object.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,10 @@ class task_manager {
852852
}
853853

854854
void resolve(lean_task_object * t, object * v) {
855+
if (t->m_value) {
856+
dec(v);
857+
return;
858+
}
855859
unique_lock<mutex> lock(m_mutex);
856860
if (t->m_value) {
857861
lock.unlock(); // `dec(v)` could lead to `deactivate_task` trying to take the lock

0 commit comments

Comments
 (0)