Skip to content

Commit

Permalink
src: add Env() to AsyncContext
Browse files Browse the repository at this point in the history
PR-URL: #568
Reviewed-By: NickNaso <nicoladelgobbo@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information
rolftimmermans authored and mhdawson committed Oct 23, 2019
1 parent ea9ce1c commit 740c798
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions doc/async_context.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ The `Napi::AsyncContext` to be destroyed.
virtual Napi::AsyncContext::~AsyncContext();
```

### Env

Requests the environment in which the async context has been initially created.

```cpp
Napi::Env Env() const;
```

Returns the `Napi::Env` environment in which the async context has been created.

## Operator

```cpp
Expand Down
4 changes: 4 additions & 0 deletions napi-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3589,6 +3589,10 @@ inline AsyncContext::operator napi_async_context() const {
return _context;
}

inline Napi::Env AsyncContext::Env() const {
return Napi::Env(_env);
}

////////////////////////////////////////////////////////////////////////////////
// AsyncWorker class
////////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 2 additions & 0 deletions napi.h
Original file line number Diff line number Diff line change
Expand Up @@ -1784,6 +1784,8 @@ namespace Napi {

operator napi_async_context() const;

Napi::Env Env() const;

private:
napi_env _env;
napi_async_context _context;
Expand Down

0 comments on commit 740c798

Please sign in to comment.