summaryrefslogtreecommitdiff
path: root/ext/web/timers.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-09-04 23:05:06 +0200
committerGitHub <noreply@github.com>2023-09-04 17:05:06 -0400
commit9e243d22f4ea9642e24415e5484f0f067f466ef5 (patch)
treef58d35fc9ac4e9fb72e14f5dab054a353b817836 /ext/web/timers.rs
parent2cc7c8432fc74b734e9d2b0c34c6a9ab434e5781 (diff)
Revert "refactor: rewrite ops that use 'deferred' to use 'op2(async(lazy))' (#20303) (#20370)
This reverts commit https://github.com/denoland/deno/commit/83426be6eead06c680ae527468aeaf8723543ff2. Includes a regression test.
Diffstat (limited to 'ext/web/timers.rs')
-rw-r--r--ext/web/timers.rs11
1 files changed, 4 insertions, 7 deletions
diff --git a/ext/web/timers.rs b/ext/web/timers.rs
index 3a4e6cb06..6e0759a98 100644
--- a/ext/web/timers.rs
+++ b/ext/web/timers.rs
@@ -5,7 +5,6 @@
use crate::hr_timer_lock::hr_timer_lock;
use deno_core::error::AnyError;
use deno_core::op;
-use deno_core::op2;
use deno_core::CancelFuture;
use deno_core::CancelHandle;
use deno_core::OpState;
@@ -80,15 +79,13 @@ pub fn op_timer_handle(state: &mut OpState) -> ResourceId {
/// [`TimerHandle`] resource given by `rid` has been canceled.
///
/// If the timer is canceled, this returns `false`. Otherwise, it returns `true`.
-#[op2(async(lazy))]
+#[op(deferred)]
pub async fn op_sleep(
state: Rc<RefCell<OpState>>,
- #[bigint] millis: u64,
- #[smi] rid: ResourceId,
+ millis: u64,
+ rid: ResourceId,
) -> Result<bool, AnyError> {
- let Ok(handle) = state.borrow().resource_table.get::<TimerHandle>(rid) else {
- return Ok(true);
- };
+ let handle = state.borrow().resource_table.get::<TimerHandle>(rid)?;
// If a timer is requested with <=100ms resolution, request the high-res timer. Since the default
// Windows timer period is 15ms, this means a 100ms timer could fire at 115ms (15% late). We assume that