mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
Merge commit 'ddf105b646
' into sync-from-ra
This commit is contained in:
parent
0816d49d83
commit
e41ab350d6
378 changed files with 14720 additions and 3111 deletions
29
crates/salsa/tests/parallel/independent.rs
Normal file
29
crates/salsa/tests/parallel/independent.rs
Normal file
|
@ -0,0 +1,29 @@
|
|||
use crate::setup::{ParDatabase, ParDatabaseImpl};
|
||||
use salsa::ParallelDatabase;
|
||||
|
||||
/// Test two `sum` queries (on distinct keys) executing in different
|
||||
/// threads. Really just a test that `snapshot` etc compiles.
|
||||
#[test]
|
||||
fn in_par_two_independent_queries() {
|
||||
let mut db = ParDatabaseImpl::default();
|
||||
|
||||
db.set_input('a', 100);
|
||||
db.set_input('b', 10);
|
||||
db.set_input('c', 1);
|
||||
db.set_input('d', 200);
|
||||
db.set_input('e', 20);
|
||||
db.set_input('f', 2);
|
||||
|
||||
let thread1 = std::thread::spawn({
|
||||
let db = db.snapshot();
|
||||
move || db.sum("abc")
|
||||
});
|
||||
|
||||
let thread2 = std::thread::spawn({
|
||||
let db = db.snapshot();
|
||||
move || db.sum("def")
|
||||
});
|
||||
|
||||
assert_eq!(thread1.join().unwrap(), 111);
|
||||
assert_eq!(thread2.join().unwrap(), 222);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue