From 33bd9e80bb6abda131241c83b9e10964ed53b251 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 10 Aug 2017 11:53:43 +0200 Subject: [PATCH] system/FileDescriptor: add method IsReadyForWriting() --- src/system/FileDescriptor.cxx | 6 ++++++ src/system/FileDescriptor.hxx | 3 +++ 2 files changed, 9 insertions(+) diff --git a/src/system/FileDescriptor.cxx b/src/system/FileDescriptor.cxx index fc3d238f3..7fef7ed6b 100644 --- a/src/system/FileDescriptor.cxx +++ b/src/system/FileDescriptor.cxx @@ -222,4 +222,10 @@ FileDescriptor::WaitWritable(int timeout) const noexcept return Poll(POLLOUT, timeout); } +bool +FileDescriptor::IsReadyForWriting() const noexcept +{ + return WaitWritable(0) > 0; +} + #endif diff --git a/src/system/FileDescriptor.hxx b/src/system/FileDescriptor.hxx index f4b5f4548..af05fd1fb 100644 --- a/src/system/FileDescriptor.hxx +++ b/src/system/FileDescriptor.hxx @@ -180,6 +180,9 @@ public: int WaitReadable(int timeout) const noexcept; int WaitWritable(int timeout) const noexcept; + + gcc_pure + bool IsReadyForWriting() const noexcept; #endif };