mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 12:43:34 +00:00
add test for nested scopes (#10026)
# Objective - When I've tested alternative async executors with bevy a common problem is that they deadlock when we try to run nested scopes. i.e. running a multithreaded schedule from inside another multithreaded schedule. This adds a test to bevy_tasks for that so the issue can be spotted earlier while developing. ## Changelog - add a test for nested scopes.
This commit is contained in:
parent
7541bf862c
commit
202b9fce18
1 changed files with 19 additions and 0 deletions
|
@ -918,4 +918,23 @@ mod tests {
|
|||
assert!(!thread_check_failed.load(Ordering::Acquire));
|
||||
assert_eq!(count.load(Ordering::Acquire), 200);
|
||||
}
|
||||
|
||||
// This test will often freeze on other executors.
|
||||
#[test]
|
||||
fn test_nested_scopes() {
|
||||
let pool = TaskPool::new();
|
||||
let count = Arc::new(AtomicI32::new(0));
|
||||
|
||||
pool.scope(|scope| {
|
||||
scope.spawn(async {
|
||||
pool.scope(|scope| {
|
||||
scope.spawn(async {
|
||||
count.fetch_add(1, Ordering::Relaxed);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
assert_eq!(count.load(Ordering::Acquire), 1);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue