summaryrefslogtreecommitdiff
path: root/src/util.h
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2017-09-25 22:53:17 +0200
committerAnna Henningsen <anna@addaleax.net>2018-05-10 14:15:16 +0200
commit1db0039c505c6081f1d0d84cc24133ed6659e539 (patch)
treef6eab3adfb959b735d274f6c83790ef83834a21b /src/util.h
parentcac8496c2ff592198a7afd114610deccb0e178ab (diff)
downloadandroid-node-v8-1db0039c505c6081f1d0d84cc24133ed6659e539.tar.gz
android-node-v8-1db0039c505c6081f1d0d84cc24133ed6659e539.tar.bz2
android-node-v8-1db0039c505c6081f1d0d84cc24133ed6659e539.zip
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 <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h10
1 files changed, 9 insertions, 1 deletions
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<typename T, typename = void>
+struct is_callable : std::is_function<T> { };
+
+template<typename T>
+struct is_callable<T, typename std::enable_if<
+ std::is_same<decltype(void(&T::operator())), void>::value
+ >::type> : std::true_type { };
+} // namespace node
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS