diff options
author | Max Kellermann <max@duempel.org> | 2013-01-30 10:36:47 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-01-30 11:03:44 +0100 |
commit | a291415326f87afe5b42a89e9a90029b876895f2 (patch) | |
tree | 0ecd6f1e42a443ed5c96457682af3cafc39bc16c /src/event/BufferedSocket.hxx | |
parent | 4ad7456428913f5232768367f2c0694bcb4540bb (diff) | |
download | mpd-a291415326f87afe5b42a89e9a90029b876895f2.tar.gz mpd-a291415326f87afe5b42a89e9a90029b876895f2.tar.xz mpd-a291415326f87afe5b42a89e9a90029b876895f2.zip |
event/BufferedSocket: move output buffer to FullyBufferedSocket
BufferedSocket has just an input buffer, and FullyBufferedSocket adds
the output buffer.
Diffstat (limited to 'src/event/BufferedSocket.hxx')
-rw-r--r-- | src/event/BufferedSocket.hxx | 29 |
1 files changed, 7 insertions, 22 deletions
diff --git a/src/event/BufferedSocket.hxx b/src/event/BufferedSocket.hxx index 23fd97d38..86deb8d98 100644 --- a/src/event/BufferedSocket.hxx +++ b/src/event/BufferedSocket.hxx @@ -22,21 +22,19 @@ #include "check.h" #include "SocketMonitor.hxx" -#include "util/PeakBuffer.hxx" #include "gcc.h" struct fifo_buffer; -class EventLoop; -class BufferedSocket : private SocketMonitor { +/** + * A #SocketMonitor specialization that adds an input buffer. + */ +class BufferedSocket : protected SocketMonitor { fifo_buffer *input; - PeakBuffer output; public: - BufferedSocket(int _fd, EventLoop &_loop, - size_t normal_size, size_t peak_size=0) - :SocketMonitor(_fd, _loop), input(nullptr), - output(normal_size, peak_size) { + BufferedSocket(int _fd, EventLoop &_loop) + :SocketMonitor(_fd, _loop), input(nullptr) { ScheduleRead(); } @@ -44,19 +42,12 @@ public: using SocketMonitor::IsDefined; using SocketMonitor::Close; + using SocketMonitor::Write; private: - ssize_t DirectWrite(const void *data, size_t length); ssize_t DirectRead(void *data, size_t length); /** - * Send data from the output buffer to the socket. - * - * @return false if the socket has been closed - */ - bool WriteFromBuffer(); - - /** * Receive data from the socket to the input buffer. * * @return false if the socket has been closed @@ -67,11 +58,6 @@ protected: /** * @return false if the socket has been closed */ - bool Write(const void *data, size_t length); - - /** - * @return false if the socket has been closed - */ bool ResumeInput(); /** @@ -112,7 +98,6 @@ protected: virtual void OnSocketError(GError *error) = 0; virtual void OnSocketClosed() = 0; -private: virtual bool OnSocketReady(unsigned flags) override; }; |