0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2024-12-27 01:29:19 -05:00

There should be a single entry point for creating IsolateHandle (#361)

This commit is contained in:
Ryan Dahl 2020-04-23 16:46:53 -04:00 committed by GitHub
parent db5bbf6e43
commit 11340c9ca3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View file

@ -59,7 +59,7 @@ impl<T> Global<T> {
Self {
value: other_value
.map(|v| unsafe { transmute(v8__Global__New(isolate, transmute(v))) }),
isolate_handle: other_value.map(|_| IsolateHandle::new(isolate)),
isolate_handle: other_value.map(|_| isolate.thread_safe_handle()),
}
}
@ -104,7 +104,7 @@ impl<T> Global<T> {
)
},
}
self.isolate_handle = other_value.map(|_| IsolateHandle::new(isolate));
self.isolate_handle = other_value.map(|_| isolate.thread_safe_handle());
}
/// If non-empty, destroy the underlying storage cell

View file

@ -431,6 +431,12 @@ impl IsolateAnnex {
}
}
/// IsolateHandle is a thread-safe reference to an Isolate. It's main use is to
/// terminate execution of a running isolate from another thread.
///
/// It is created with Isolate::thread_safe_handle().
///
/// IsolateHandle is Cloneable, Send, and Sync.
#[derive(Clone)]
pub struct IsolateHandle(Arc<IsolateAnnex>);
@ -445,7 +451,7 @@ impl IsolateHandle {
self.0.isolate
}
pub(crate) fn new(isolate: &mut Isolate) -> Self {
fn new(isolate: &mut Isolate) -> Self {
Self(isolate.get_annex_arc())
}