summaryrefslogtreecommitdiff
path: root/runtime/ops/timers.rs
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/ops/timers.rs')
-rw-r--r--runtime/ops/timers.rs24
1 files changed, 8 insertions, 16 deletions
diff --git a/runtime/ops/timers.rs b/runtime/ops/timers.rs
index 34a3eea5f..7c1718ce7 100644
--- a/runtime/ops/timers.rs
+++ b/runtime/ops/timers.rs
@@ -8,9 +8,6 @@
//! only need to be able to start, cancel and await a single timer (or Delay, as Tokio
//! calls it) for an entire Isolate. This is what is implemented here.
-use super::dispatch_minimal::minimal_op;
-use super::dispatch_minimal::MinimalOp;
-use crate::metrics::metrics_op;
use crate::permissions::Permissions;
use deno_core::error::type_error;
use deno_core::error::AnyError;
@@ -81,7 +78,7 @@ pub fn init(rt: &mut deno_core::JsRuntime) {
super::reg_json_sync(rt, "op_global_timer_stop", op_global_timer_stop);
super::reg_json_sync(rt, "op_global_timer_start", op_global_timer_start);
super::reg_json_async(rt, "op_global_timer", op_global_timer);
- rt.register_op("op_now", metrics_op("op_now", minimal_op(op_now)));
+ super::reg_buffer_sync(rt, "op_now", op_now);
super::reg_json_sync(rt, "op_sleep_sync", op_sleep_sync);
}
@@ -143,21 +140,16 @@ async fn op_global_timer(
// If the High precision flag is not set, the
// nanoseconds are rounded on 2ms.
fn op_now(
- state: Rc<RefCell<OpState>>,
- // Arguments are discarded
- _sync: bool,
- _x: i32,
- mut zero_copy: BufVec,
-) -> MinimalOp {
+ op_state: &mut OpState,
+ _argument: u32,
+ zero_copy: &mut [ZeroCopyBuf],
+) -> Result<u32, AnyError> {
match zero_copy.len() {
- 0 => return MinimalOp::Sync(Err(type_error("no buffer specified"))),
+ 0 => return Err(type_error("no buffer specified")),
1 => {}
- _ => {
- return MinimalOp::Sync(Err(type_error("Invalid number of arguments")))
- }
+ _ => return Err(type_error("Invalid number of arguments")),
}
- let op_state = state.borrow();
let start_time = op_state.borrow::<StartTime>();
let seconds = start_time.elapsed().as_secs();
let mut subsec_nanos = start_time.elapsed().subsec_nanos() as f64;
@@ -174,7 +166,7 @@ fn op_now(
(&mut zero_copy[0]).copy_from_slice(&result.to_be_bytes());
- MinimalOp::Sync(Ok(0))
+ Ok(0)
}
#[derive(Deserialize)]