Commit 1c079e55 authored by Max Kellermann's avatar Max Kellermann

io/UniqueFileDescriptor: add method Release()

parent 48afb68f
...@@ -64,6 +64,14 @@ public: ...@@ -64,6 +64,14 @@ public:
return *this; return *this;
} }
/**
* Release ownership and return the descriptor as an unmanaged
* #FileDescriptor instance.
*/
FileDescriptor Release() noexcept {
return std::exchange(*(FileDescriptor *)this, Undefined());
}
protected: protected:
void Set(int _fd) noexcept { void Set(int _fd) noexcept {
assert(!IsDefined()); assert(!IsDefined());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment