diff options
author | Aaron O'Mullan <aaron.omullan@gmail.com> | 2021-10-10 17:20:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-10 17:20:30 +0200 |
commit | 5a8a989b7815023f33a1e3183a55cc8999af5d98 (patch) | |
tree | d15619ed83a2965f17dc10a78c9072f34d393009 /core/bindings.rs | |
parent | f2ac7ff23a2ae4925f4ca32ffd61c923c481ef4e (diff) |
refactor(metrics): move to core (#12386)
Avoids overhead of wrapping ops (and allocs when inspecting async-op futures)
Diffstat (limited to 'core/bindings.rs')
-rw-r--r-- | core/bindings.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/core/bindings.rs b/core/bindings.rs index cf4fd07f6..2fc6b5092 100644 --- a/core/bindings.rs +++ b/core/bindings.rs @@ -315,7 +315,7 @@ fn opcall_sync<'s>( mut rv: v8::ReturnValue, ) { let state_rc = JsRuntime::state(scope); - let state = state_rc.borrow(); + let state = state_rc.borrow_mut(); let op_id = match v8::Local::<v8::Integer>::try_from(args.get(0)) .map(|l| l.value() as OpId) @@ -344,11 +344,13 @@ fn opcall_sync<'s>( scope, a, b, + op_id, promise_id: 0, }; let op = OpTable::route_op(op_id, state.op_state.clone(), payload); match op { Op::Sync(result) => { + state.op_state.borrow_mut().tracker.track_sync(op_id); rv.set(result.to_v8(scope).unwrap()); } Op::NotFound => { @@ -405,6 +407,7 @@ fn opcall_async<'s>( scope, a, b, + op_id, promise_id, }; let op = OpTable::route_op(op_id, state.op_state.clone(), payload); @@ -417,10 +420,12 @@ fn opcall_async<'s>( OpResult::Err(_) => rv.set(result.to_v8(scope).unwrap()), }, Op::Async(fut) => { + state.op_state.borrow_mut().tracker.track_async(op_id); state.pending_ops.push(fut); state.have_unpolled_ops = true; } Op::AsyncUnref(fut) => { + state.op_state.borrow_mut().tracker.track_unref(op_id); state.pending_unref_ops.push(fut); state.have_unpolled_ops = true; } |