| 8 | namespace { |
| 9 | |
| 10 | static Value TestUnref(const CallbackInfo& info) { |
| 11 | Napi::Env env = info.Env(); |
| 12 | Object global = env.Global(); |
| 13 | Object resource = info[0].As<Object>(); |
| 14 | Function cb = info[1].As<Function>(); |
| 15 | Function setTimeout = MaybeUnwrap(global.Get("setTimeout")).As<Function>(); |
| 16 | ThreadSafeFunction* tsfn = new ThreadSafeFunction; |
| 17 | |
| 18 | *tsfn = ThreadSafeFunction::New( |
| 19 | info.Env(), cb, resource, "Test", 1, 1, [tsfn](Napi::Env /* env */) { |
| 20 | delete tsfn; |
| 21 | }); |
| 22 | |
| 23 | tsfn->BlockingCall(); |
| 24 | |
| 25 | setTimeout.Call( |
| 26 | global, |
| 27 | {Function::New( |
| 28 | env, [tsfn](const CallbackInfo& info) { tsfn->Unref(info.Env()); }), |
| 29 | Number::New(env, 100)}); |
| 30 | |
| 31 | return info.Env().Undefined(); |
| 32 | } |
| 33 | |
| 34 | static Value TestRef(const CallbackInfo& info) { |
| 35 | Function cb = info[1].As<Function>(); |
nothing calls this directly
no test coverage detected