| 8 | namespace { |
| 9 | |
| 10 | class TSFNWrap : public ObjectWrap<TSFNWrap> { |
| 11 | public: |
| 12 | static Function Init(Napi::Env env); |
| 13 | TSFNWrap(const CallbackInfo& info); |
| 14 | |
| 15 | Napi::Value GetContext(const CallbackInfo& /*info*/) { |
| 16 | Reference<Napi::Value>* ctx = _tsfn.GetContext(); |
| 17 | return ctx->Value(); |
| 18 | }; |
| 19 | |
| 20 | Napi::Value Release(const CallbackInfo& info) { |
| 21 | Napi::Env env = info.Env(); |
| 22 | _deferred = std::unique_ptr<Promise::Deferred>(new Promise::Deferred(env)); |
| 23 | _tsfn.Release(); |
| 24 | return _deferred->Promise(); |
| 25 | }; |
| 26 | |
| 27 | private: |
| 28 | ThreadSafeFunction _tsfn; |
| 29 | std::unique_ptr<Promise::Deferred> _deferred; |
| 30 | }; |
| 31 | |
| 32 | Function TSFNWrap::Init(Napi::Env env) { |
| 33 | Function func = |
nothing calls this directly
no outgoing calls
no test coverage detected