summaryrefslogtreecommitdiff
path: root/src/io/UniqueFileDescriptor.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2020-10-14 20:37:29 +0200
committerMax Kellermann <max@musicpd.org>2020-10-14 20:50:02 +0200
commit1c079e554bdb021ccdab2e47c8cbb05064c973db (patch)
treea8bad120519072f0164d2cfca17d427a2078687e /src/io/UniqueFileDescriptor.hxx
parent48afb68f3a6ef5906c90613230d0a82a00ec5c44 (diff)
io/UniqueFileDescriptor: add method Release()
Diffstat (limited to 'src/io/UniqueFileDescriptor.hxx')
-rw-r--r--src/io/UniqueFileDescriptor.hxx8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/io/UniqueFileDescriptor.hxx b/src/io/UniqueFileDescriptor.hxx
index 0a6c03c8e..a8bbbea3f 100644
--- a/src/io/UniqueFileDescriptor.hxx
+++ b/src/io/UniqueFileDescriptor.hxx
@@ -64,6 +64,14 @@ public:
return *this;
}
+ /**
+ * Release ownership and return the descriptor as an unmanaged
+ * #FileDescriptor instance.
+ */
+ FileDescriptor Release() noexcept {
+ return std::exchange(*(FileDescriptor *)this, Undefined());
+ }
+
protected:
void Set(int _fd) noexcept {
assert(!IsDefined());