Skip to content

Commit 740c798

Browse files
rolftimmermansmhdawson
authored andcommitted
src: add Env() to AsyncContext
PR-URL: #568 Reviewed-By: NickNaso <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent ea9ce1c commit 740c798

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

doc/async_context.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ The `Napi::AsyncContext` to be destroyed.
4545
virtual Napi::AsyncContext::~AsyncContext();
4646
```
4747

48+
### Env
49+
50+
Requests the environment in which the async context has been initially created.
51+
52+
```cpp
53+
Napi::Env Env() const;
54+
```
55+
56+
Returns the `Napi::Env` environment in which the async context has been created.
57+
4858
## Operator
4959

5060
```cpp

napi-inl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3589,6 +3589,10 @@ inline AsyncContext::operator napi_async_context() const {
35893589
return _context;
35903590
}
35913591

3592+
inline Napi::Env AsyncContext::Env() const {
3593+
return Napi::Env(_env);
3594+
}
3595+
35923596
////////////////////////////////////////////////////////////////////////////////
35933597
// AsyncWorker class
35943598
////////////////////////////////////////////////////////////////////////////////

napi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,6 +1784,8 @@ namespace Napi {
17841784

17851785
operator napi_async_context() const;
17861786

1787+
Napi::Env Env() const;
1788+
17871789
private:
17881790
napi_env _env;
17891791
napi_async_context _context;

0 commit comments

Comments
 (0)