Skip to content

Commit

Permalink
async_wrap: add GetAsyncId() method
Browse files Browse the repository at this point in the history
Allow handles to retrieve their own uid's by adding a new method on the
FunctionTemplates. Implementation of these into all other classes will
come in a future commit.
  • Loading branch information
trevnorris committed Mar 15, 2017
1 parent c5c690d commit 3da0b78
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/async-wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,14 @@ AsyncWrap::~AsyncWrap() {
}


void AsyncWrap::GetAsyncId(const FunctionCallbackInfo<Value>& args) {
AsyncWrap* wrap;
args.GetReturnValue().Set(-1);
ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder());
args.GetReturnValue().Set(wrap->get_id());
}


Local<Value> AsyncWrap::MakeCallback(const Local<Function> cb,
int argc,
Local<Value>* argv) {
Expand Down
2 changes: 2 additions & 0 deletions src/async-wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ class AsyncWrap : public BaseObject {
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context);

static void GetAsyncId(const v8::FunctionCallbackInfo<v8::Value>& args);

static void DestroyIdsCb(uv_idle_t* handle);

inline ProviderType provider_type() const;
Expand Down

0 comments on commit 3da0b78

Please sign in to comment.