summaryrefslogtreecommitdiff
path: root/ext/web/timers.rs
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2022-03-14 23:14:15 +0530
committerGitHub <noreply@github.com>2022-03-14 18:44:15 +0100
commitb4e42953e1d243f2eda20e5be6b845d60b7bf688 (patch)
tree10b3bfff165f9c04f9174c7c399d44b9b724c3b3 /ext/web/timers.rs
parent4e3ed37037a2aa1edeac260dc3463a81d9cf9b88 (diff)
feat(core): codegen ops (#13861)
Co-authored-by: Aaron O'Mullan <aaron.omullan@gmail.com>
Diffstat (limited to 'ext/web/timers.rs')
-rw-r--r--ext/web/timers.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/ext/web/timers.rs b/ext/web/timers.rs
index 7f17aa969..9a78240f7 100644
--- a/ext/web/timers.rs
+++ b/ext/web/timers.rs
@@ -3,6 +3,8 @@
//! This module helps deno implement timers and performance APIs.
use deno_core::error::AnyError;
+use deno_core::op;
+
use deno_core::CancelFuture;
use deno_core::CancelHandle;
use deno_core::OpState;
@@ -25,6 +27,7 @@ pub type StartTime = Instant;
// since the start time of the deno runtime.
// If the High precision flag is not set, the
// nanoseconds are rounded on 2ms.
+#[op]
pub fn op_now<TP>(
state: &mut OpState,
_argument: (),
@@ -64,6 +67,7 @@ impl Resource for TimerHandle {
/// Creates a [`TimerHandle`] resource that can be used to cancel invocations of
/// [`op_sleep`].
+#[op]
pub fn op_timer_handle(
state: &mut OpState,
_: (),
@@ -77,6 +81,7 @@ pub fn op_timer_handle(
/// Waits asynchronously until either `millis` milliseconds have passed or the
/// [`TimerHandle`] resource given by `rid` has been canceled.
+#[op]
pub async fn op_sleep(
state: Rc<RefCell<OpState>>,
millis: u64,
@@ -89,6 +94,7 @@ pub async fn op_sleep(
Ok(())
}
+#[op]
pub fn op_sleep_sync<TP>(
state: &mut OpState,
millis: u64,