From 1db0039c505c6081f1d0d84cc24133ed6659e539 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Mon, 25 Sep 2017 22:53:17 +0200 Subject: src: keep track of open requests Workers cannot shut down while requests are open, so keep a counter that is increased whenever libuv requests are made and decreased whenever their callback is called. This also applies to other embedders, who may want to shut down an `Environment` instance early. Many thanks for Stephen Belanger for reviewing the original version of this commit in the Ayo.js project. Fixes: https://github.com/nodejs/node/issues/20517 Refs: https://github.com/ayojs/ayo/pull/85 PR-URL: https://github.com/nodejs/node/pull/19377 Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell --- src/util.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/util.h') diff --git a/src/util.h b/src/util.h index 7a1c6c109f..2c66104e9d 100644 --- a/src/util.h +++ b/src/util.h @@ -447,8 +447,16 @@ struct MallocedBuffer { MallocedBuffer& operator=(const MallocedBuffer&) = delete; }; -} // namespace node +// Test whether some value can be called with (). +template +struct is_callable : std::is_function { }; + +template +struct is_callable::value + >::type> : std::true_type { }; +} // namespace node #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS -- cgit v1.2.3