mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
Remove ntasks aliasing workaround
This commit is contained in:
parent
ad4c4c214a
commit
d86e5d2605
1 changed files with 7 additions and 13 deletions
|
@ -44,12 +44,7 @@ pub struct Isolate {
|
||||||
libdeno_isolate: *const libdeno::isolate,
|
libdeno_isolate: *const libdeno::isolate,
|
||||||
dispatch: Dispatch,
|
dispatch: Dispatch,
|
||||||
rx: mpsc::Receiver<(i32, Buf)>,
|
rx: mpsc::Receiver<(i32, Buf)>,
|
||||||
// Although Isolate is only accessed on the main thread, we use an atomic
|
ntasks: i32,
|
||||||
// variable here to workaround an issue probably caused by our poor usage
|
|
||||||
// of Box::leak in Isolate::from_c()
|
|
||||||
// https://github.com/denoland/deno/issues/919
|
|
||||||
// ntasks ought to be i32.
|
|
||||||
ntasks: atomic::AtomicIsize,
|
|
||||||
pub timeout_due: Option<Instant>,
|
pub timeout_due: Option<Instant>,
|
||||||
pub state: Arc<IsolateState>,
|
pub state: Arc<IsolateState>,
|
||||||
}
|
}
|
||||||
|
@ -91,7 +86,7 @@ impl Isolate {
|
||||||
libdeno_isolate: 0 as *const libdeno::isolate,
|
libdeno_isolate: 0 as *const libdeno::isolate,
|
||||||
dispatch,
|
dispatch,
|
||||||
rx,
|
rx,
|
||||||
ntasks: atomic::AtomicIsize::new(0),
|
ntasks: 0,
|
||||||
timeout_due: None,
|
timeout_due: None,
|
||||||
state: Arc::new(IsolateState {
|
state: Arc::new(IsolateState {
|
||||||
dir: deno_dir::DenoDir::new(flags.reload, None).unwrap(),
|
dir: deno_dir::DenoDir::new(flags.reload, None).unwrap(),
|
||||||
|
@ -195,18 +190,17 @@ impl Isolate {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ntasks_increment(&mut self) {
|
fn ntasks_increment(&mut self) {
|
||||||
let previous_ntasks = self.ntasks.fetch_add(1, atomic::Ordering::SeqCst);
|
assert!(self.ntasks >= 0);
|
||||||
assert!(previous_ntasks >= 0);
|
self.ntasks = self.ntasks + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ntasks_decrement(&mut self) {
|
fn ntasks_decrement(&mut self) {
|
||||||
let previous_ntasks = self.ntasks.fetch_sub(1, atomic::Ordering::SeqCst);
|
self.ntasks = self.ntasks - 1;
|
||||||
assert!(previous_ntasks >= 1);
|
assert!(self.ntasks >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_idle(&self) -> bool {
|
fn is_idle(&self) -> bool {
|
||||||
let n = self.ntasks.load(atomic::Ordering::SeqCst);
|
self.ntasks == 0 && self.timeout_due.is_none()
|
||||||
n == 0 && self.timeout_due.is_none()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue