mirror of
https://github.com/debauchee/barrier.git
synced 2026-07-05 11:28:22 +08:00
Started over.
This commit is contained in:
51
io/CBufferedInputStream.h
Normal file
51
io/CBufferedInputStream.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#ifndef CBUFFEREDINPUTSTREAM_H
|
||||
#define CBUFFEREDINPUTSTREAM_H
|
||||
|
||||
#include "CStreamBuffer.h"
|
||||
#include "CCondVar.h"
|
||||
#include "IInputStream.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) throw();
|
||||
|
||||
// causes read() to always return immediately. if there is no
|
||||
// more data then it returns 0. further writes are discarded.
|
||||
void hangup() throw();
|
||||
|
||||
// same as read() but caller must lock the mutex
|
||||
UInt32 readNoLock(void*, UInt32 count) throw(XIO);
|
||||
|
||||
// accessors
|
||||
|
||||
// same as getSize() but caller must lock the mutex
|
||||
UInt32 getSizeNoLock() const throw();
|
||||
|
||||
// IInputStream overrides
|
||||
// these all lock the mutex for their duration
|
||||
virtual void close() throw(XIO);
|
||||
virtual UInt32 read(void*, UInt32 count) throw(XIO);
|
||||
virtual UInt32 getSize() const throw();
|
||||
|
||||
private:
|
||||
CMutex* m_mutex;
|
||||
CCondVar<bool> m_empty;
|
||||
IJob* m_closeCB;
|
||||
CStreamBuffer m_buffer;
|
||||
bool m_closed;
|
||||
bool m_hungup;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user