only use Locker when calling into js (#2665)

This commit is contained in:
andy finch 2019-07-18 20:23:14 -04:00 committed by Ryan Dahl
parent 042484d45a
commit 621af21e6e
1 changed files with 6 additions and 3 deletions

View File

@ -550,9 +550,6 @@ impl Future for Isolate {
type Error = ErrBox;
fn poll(&mut self) -> Poll<(), ErrBox> {
// Lock the current thread for V8.
let _locker = LockerScope::new(self.libdeno_isolate);
self.shared_init();
let mut overflow_response: Option<Buf> = None;
@ -590,14 +587,20 @@ impl Future for Isolate {
}
if self.shared.size() > 0 {
// Lock the current thread for V8.
let locker = LockerScope::new(self.libdeno_isolate);
self.respond(None)?;
// The other side should have shifted off all the messages.
assert_eq!(self.shared.size(), 0);
drop(locker);
}
if overflow_response.is_some() {
// Lock the current thread for V8.
let locker = LockerScope::new(self.libdeno_isolate);
let buf = overflow_response.take().unwrap();
self.respond(Some(&buf))?;
drop(locker);
}
self.check_promise_errors();