Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Env() to AsyncContext. #568

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -3593,6 +3593,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