mirror of
https://github.com/debauchee/barrier.git
synced 2026-02-08 21:03:54 +08:00
init() it while it's already running. fixed an uninitialized pointer bug in CServer and some cleanup-on-error code in CMSWindowsPrimaryScreen. also added timeout to read() on IInputStream and a heartbeat sent by clients so the server can disconnect clients that are dead but never reset the TCP connection. previously the server would keep these dead clients around forever and if the user was locked on the client screen for some reason then the server would have to be rebooted (or the server would have to be killed via a remote login).
52 lines
1.2 KiB
C++
52 lines
1.2 KiB
C++
#ifndef CBUFFEREDINPUTSTREAM_H
|
|
#define CBUFFEREDINPUTSTREAM_H
|
|
|
|
#include "IInputStream.h"
|
|
#include "CStreamBuffer.h"
|
|
#include "CCondVar.h"
|
|
|
|
class CMutex;
|
|
class IJob;
|
|
|
|
class CBufferedInputStream : public IInputStream {
|
|
public:
|
|
CBufferedInputStream(CMutex*, IJob* adoptedCloseCB);
|
|
~CBufferedInputStream();
|
|
|
|
// the caller is expected to lock the mutex before calling
|
|
// methods unless otherwise noted.
|
|
|
|
// manipulators
|
|
|
|
// write() appends n bytes to the buffer
|
|
void write(const void*, UInt32 n);
|
|
|
|
// causes read() to always return immediately. if there is no
|
|
// more data then it returns 0. further writes are discarded.
|
|
void hangup();
|
|
|
|
// same as read() but caller must lock the mutex
|
|
UInt32 readNoLock(void*, UInt32 count, double timeout);
|
|
|
|
// accessors
|
|
|
|
// same as getSize() but caller must lock the mutex
|
|
UInt32 getSizeNoLock() const;
|
|
|
|
// IInputStream overrides
|
|
// these all lock the mutex for their duration
|
|
virtual void close();
|
|
virtual UInt32 read(void*, UInt32 count, double timeout);
|
|
virtual UInt32 getSize() const;
|
|
|
|
private:
|
|
CMutex* m_mutex;
|
|
CCondVar<bool> m_empty;
|
|
IJob* m_closeCB;
|
|
CStreamBuffer m_buffer;
|
|
bool m_closed;
|
|
bool m_hungup;
|
|
};
|
|
|
|
#endif
|