0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2025-01-12 00:54:15 -05:00
denoland-rusty-v8/tests/compile_fail/handle_scope_lifetimes.rs
Ryan Dahl 32abe84dc6
Remove v8::Locker (#272)
This patch clarifies that v8::Isolate is a single threaded creature,
which can only be accessed from other threads in special circumstances.
To ensure optimal operation in Deno, we remove v8::Locker, which ought
to be unnecessary when a thread is dedicated to each Isolate and the
Isolates never move between threads.

There are valid use-cases for v8::Locker, and we hope to address them in
future versions of rusty_v8.

Co-authored-by: Bert Belder <bertbelder@gmail.com>
2020-02-11 17:01:27 -05:00

42 lines
1 KiB
Rust

// Copyright 2019-2020 the Deno authors. All rights reserved. MIT license.
use rusty_v8 as v8;
pub fn main() {
let mut isolate = v8::Isolate::new(mock());
let mut root_hs = v8::HandleScope::new(&mut isolate);
let root_hs = root_hs.enter();
{
let mut hs = v8::EscapableHandleScope::new(root_hs);
let hs = hs.enter();
let _fail = v8::EscapableHandleScope::new(root_hs);
let _local = v8::Integer::new(hs, 123);
}
{
let mut hs1 = v8::EscapableHandleScope::new(root_hs);
let hs1 = hs1.enter();
let _local1 = v8::Integer::new(hs1, 123);
let mut hs2 = v8::EscapableHandleScope::new(hs1);
let hs2 = hs2.enter();
let _fail = v8::Integer::new(hs1, 123);
let _local2 = v8::Integer::new(hs2, 123);
let _local3 = v8::Integer::new(hs2, 123);
}
let _leak1 = {
let mut hs = v8::EscapableHandleScope::new(root_hs);
let hs = hs.enter();
v8::Integer::new(hs, 456)
};
let _leak = {
let mut hs = v8::EscapableHandleScope::new(root_hs);
hs.enter()
};
}
fn mock<T>() -> T {
unimplemented!()
}