0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2024-11-29 16:31:01 -05:00
denoland-rusty-v8/tests/test_concurrent_isolate_creation_and_disposal.rs
2022-01-04 21:32:48 +01:00

32 lines
733 B
Rust

// This is flaky on cross (QEMU bug)
// but otherwise works fine on real device.
#![cfg(not(target_os = "android"))]
use std::iter::repeat_with;
use std::thread;
#[test]
fn concurrent_isolate_creation_and_disposal() {
let platform = v8::new_single_threaded_default_platform(false).make_shared();
v8::V8::initialize_platform(platform);
v8::V8::initialize();
for round in 0..1000 {
eprintln!("round {}", round);
let threads = repeat_with(|| {
thread::spawn(|| {
v8::Isolate::new(Default::default());
})
})
.take(16)
.collect::<Vec<_>>();
for join_handle in threads {
join_handle.join().unwrap();
}
}
unsafe { v8::V8::dispose() };
v8::V8::shutdown_platform();
}