diff options
author | Max Kellermann <max@musicpd.org> | 2020-10-14 20:37:29 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2020-10-14 20:50:02 +0200 |
commit | 1c079e554bdb021ccdab2e47c8cbb05064c973db (patch) | |
tree | a8bad120519072f0164d2cfca17d427a2078687e /src/io/UniqueFileDescriptor.hxx | |
parent | 48afb68f3a6ef5906c90613230d0a82a00ec5c44 (diff) |
io/UniqueFileDescriptor: add method Release()
Diffstat (limited to 'src/io/UniqueFileDescriptor.hxx')
-rw-r--r-- | src/io/UniqueFileDescriptor.hxx | 8 |
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()); |