mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-08-04 11:00:05 +00:00
Short-circuit block-on
if same thread (#862)
Some checks failed
Test / Test (push) Has been cancelled
Book / Book (push) Has been cancelled
Release-plz / Release-plz release (push) Has been cancelled
Release-plz / Release-plz PR (push) Has been cancelled
Test / Miri (push) Has been cancelled
Test / Benchmarks (push) Has been cancelled
Book / Deploy (push) Has been cancelled
Some checks failed
Test / Test (push) Has been cancelled
Book / Book (push) Has been cancelled
Release-plz / Release-plz release (push) Has been cancelled
Release-plz / Release-plz PR (push) Has been cancelled
Test / Miri (push) Has been cancelled
Test / Benchmarks (push) Has been cancelled
Book / Deploy (push) Has been cancelled
* Short-circuit `block_on` if same thread * Avoid acquiring the lock
This commit is contained in:
parent
18dc594dea
commit
678f51a745
1 changed files with 6 additions and 1 deletions
|
@ -172,8 +172,13 @@ impl Runtime {
|
||||||
other_id: ThreadId,
|
other_id: ThreadId,
|
||||||
query_mutex_guard: QueryMutexGuard,
|
query_mutex_guard: QueryMutexGuard,
|
||||||
) -> BlockResult {
|
) -> BlockResult {
|
||||||
let dg = self.dependency_graph.lock();
|
|
||||||
let thread_id = thread::current().id();
|
let thread_id = thread::current().id();
|
||||||
|
// Cycle in the same thread.
|
||||||
|
if thread_id == other_id {
|
||||||
|
return BlockResult::Cycle;
|
||||||
|
}
|
||||||
|
|
||||||
|
let dg = self.dependency_graph.lock();
|
||||||
|
|
||||||
if dg.depends_on(other_id, thread_id) {
|
if dg.depends_on(other_id, thread_id) {
|
||||||
return BlockResult::Cycle;
|
return BlockResult::Cycle;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue