Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2020-04-09 19:45:15 +0300
committerAnna Henningsen <anna@addaleax.net>2020-06-14 15:53:38 +0300
commit57e7c63f74255e3287a11393bb4c18d0ab4e7b1d (patch)
treebb671cf3d3762180c73e16a1a171df23884f9f41 /src/util.h
parent8a7201b25fa2e5342b5d737742586bcd5ea1da5e (diff)
worker: allow transferring/cloning generic BaseObjects
Extend support for transferring objects à la `MessagePort` to other types of `BaseObject` subclasses, as well as implement cloning support for cases in which destructive transferring is not needed or optional. PR-URL: https://github.com/nodejs/node/pull/33772 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/util.h b/src/util.h
index 62229e3c448..8bdeb35184e 100644
--- a/src/util.h
+++ b/src/util.h
@@ -784,6 +784,12 @@ class FastStringKey {
size_t cached_hash_;
};
+// Like std::static_pointer_cast but for unique_ptr with the default deleter.
+template <typename T, typename U>
+std::unique_ptr<T> static_unique_pointer_cast(std::unique_ptr<U>&& ptr) {
+ return std::unique_ptr<T>(static_cast<T*>(ptr.release()));
+}
+
} // namespace node
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS