summaryrefslogtreecommitdiff
path: root/src/event/FullyBufferedSocket.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2020-10-14 13:34:15 +0200
committerMax Kellermann <max@musicpd.org>2020-10-14 13:47:25 +0200
commit1686f4e857769650474498de40f12b13a5889ba1 (patch)
tree0c4b719b7a6c426af537c62f1fbe9424f0508c0f /src/event/FullyBufferedSocket.hxx
parent9f57732af2c2f587b5262bcf3a9119f068476a40 (diff)
event/IdleMonitor: refactor to IdleEvent
Instead of using this as a base class implementing a virtual method, the new class IdleEvent can be used as a variable, decoupling IdleMonitor's internal state from the derived class. This is similar to commit 30a5dd267b6cb9ee21106d5d949de2f04781c6e7 which refactored TimeoutMonitor to TimerEvent.
Diffstat (limited to 'src/event/FullyBufferedSocket.hxx')
-rw-r--r--src/event/FullyBufferedSocket.hxx13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/event/FullyBufferedSocket.hxx b/src/event/FullyBufferedSocket.hxx
index 6a33ab155..2642ec705 100644
--- a/src/event/FullyBufferedSocket.hxx
+++ b/src/event/FullyBufferedSocket.hxx
@@ -21,19 +21,22 @@
#define MPD_FULLY_BUFFERED_SOCKET_HXX
#include "BufferedSocket.hxx"
-#include "IdleMonitor.hxx"
+#include "IdleEvent.hxx"
#include "util/PeakBuffer.hxx"
/**
* A #BufferedSocket specialization that adds an output buffer.
*/
-class FullyBufferedSocket : protected BufferedSocket, private IdleMonitor {
+class FullyBufferedSocket : protected BufferedSocket {
+ IdleEvent idle_event;
+
PeakBuffer output;
public:
FullyBufferedSocket(SocketDescriptor _fd, EventLoop &_loop,
size_t normal_size, size_t peak_size=0) noexcept
- :BufferedSocket(_fd, _loop), IdleMonitor(_loop),
+ :BufferedSocket(_fd, _loop),
+ idle_event(_loop, BIND_THIS_METHOD(OnIdle)),
output(normal_size, peak_size) {
}
@@ -41,7 +44,7 @@ public:
using BufferedSocket::IsDefined;
void Close() noexcept {
- IdleMonitor::Cancel();
+ idle_event.Cancel();
BufferedSocket::Close();
}
@@ -69,7 +72,7 @@ protected:
/* virtual methods from class SocketMonitor */
bool OnSocketReady(unsigned flags) noexcept override;
- void OnIdle() noexcept override;
+ void OnIdle() noexcept;
};
#endif