Skip to content

Commit

Permalink
chore(core): remove have_unpolled_ops on rt state (#17601)
Browse files Browse the repository at this point in the history
It's not needed - `!state.have_unpolled_ops.is_empty()` does the same
thing.

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
  • Loading branch information
lucacasonato and bartlomieju committed Jan 31, 2023
1 parent d318e38 commit e85ca8b
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions core/runtime.rs
Expand Up @@ -179,7 +179,6 @@ pub struct JsRuntimeState {
pub(crate) source_map_getter: Option<Box<dyn SourceMapGetter>>,
pub(crate) source_map_cache: SourceMapCache,
pub(crate) pending_ops: FuturesUnordered<PendingOpFuture>,
pub(crate) have_unpolled_ops: bool,
pub(crate) op_state: Rc<RefCell<OpState>>,
pub(crate) shared_array_buffer_store: Option<SharedArrayBufferStore>,
pub(crate) compiled_wasm_module_store: Option<CompiledWasmModuleStore>,
Expand Down Expand Up @@ -398,7 +397,6 @@ impl JsRuntime {
compiled_wasm_module_store: options.compiled_wasm_module_store,
op_state: op_state.clone(),
waker: AtomicWaker::new(),
have_unpolled_ops: false,
dispatched_exceptions: Default::default(),
// Some fields are initialized later after isolate is created
inspector: None,
Expand Down Expand Up @@ -1320,7 +1318,7 @@ impl JsRuntime {
// TODO(andreubotella) The event loop will spin as long as there are pending
// background tasks. We should look into having V8 notify us when a
// background task is done.
if state.have_unpolled_ops
if !state.pending_ops.is_empty()
|| pending_state.has_pending_background_tasks
|| pending_state.has_tick_scheduled
|| maybe_scheduling
Expand Down Expand Up @@ -2259,7 +2257,6 @@ impl JsRuntime {
// Now handle actual ops.
{
let mut state = self.state.borrow_mut();
state.have_unpolled_ops = false;

while let Poll::Ready(Some(item)) = state.pending_ops.poll_next_unpin(cx)
{
Expand Down Expand Up @@ -2355,7 +2352,6 @@ impl JsRuntime {
// Now handle actual ops.
{
let mut state = self.state.borrow_mut();
state.have_unpolled_ops = false;

let realm_state_rc = state.global_realm.as_ref().unwrap().state(scope);
let mut realm_state = realm_state_rc.borrow_mut();
Expand Down Expand Up @@ -2633,9 +2629,10 @@ pub fn queue_fast_async_op(
None => unreachable!(),
};

let mut state = runtime_state.borrow_mut();
state.pending_ops.push(OpCall::lazy(op));
state.have_unpolled_ops = true;
runtime_state
.borrow_mut()
.pending_ops
.push(OpCall::lazy(op));
}

#[inline]
Expand Down Expand Up @@ -2689,14 +2686,10 @@ pub fn queue_async_op(
}
EagerPollResult::Ready(op) => {
let ready = OpCall::ready(op);
let mut state = runtime_state.borrow_mut();
state.pending_ops.push(ready);
state.have_unpolled_ops = true;
runtime_state.borrow_mut().pending_ops.push(ready);
}
EagerPollResult::Pending(op) => {
let mut state = runtime_state.borrow_mut();
state.pending_ops.push(op);
state.have_unpolled_ops = true;
runtime_state.borrow_mut().pending_ops.push(op);
}
}
}
Expand Down

0 comments on commit e85ca8b

Please sign in to comment.