mirror of
https://github.com/debauchee/barrier.git
synced 2026-07-11 06:17:40 +08:00
Started over.
This commit is contained in:
46
io/CBufferedOutputStream.h
Normal file
46
io/CBufferedOutputStream.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifndef CBUFFEREDOUTPUTSTREAM_H
|
||||
#define CBUFFEREDOUTPUTSTREAM_H
|
||||
|
||||
#include "CStreamBuffer.h"
|
||||
#include "IOutputStream.h"
|
||||
|
||||
class CMutex;
|
||||
class IJob;
|
||||
|
||||
class CBufferedOutputStream : public IOutputStream {
|
||||
public:
|
||||
CBufferedOutputStream(CMutex*, IJob* adoptedCloseCB);
|
||||
~CBufferedOutputStream();
|
||||
|
||||
// the caller is expected to lock the mutex before calling
|
||||
// methods unless otherwise noted.
|
||||
|
||||
// manipulators
|
||||
|
||||
// peek() returns a buffer of n bytes (which must be <= getSize()).
|
||||
// pop() discards the next n bytes.
|
||||
const void* peek(UInt32 n) throw();
|
||||
void pop(UInt32 n) throw();
|
||||
|
||||
// accessors
|
||||
|
||||
// return the number of bytes in the buffer
|
||||
UInt32 getSize() const throw();
|
||||
|
||||
// IOutputStream overrides
|
||||
// these all lock the mutex for their duration
|
||||
virtual void close() throw(XIO);
|
||||
virtual UInt32 write(const void*, UInt32 count) throw(XIO);
|
||||
virtual void flush() throw(XIO);
|
||||
|
||||
private:
|
||||
UInt32 getSizeWithLock() const throw();
|
||||
|
||||
private:
|
||||
CMutex* m_mutex;
|
||||
IJob* m_closeCB;
|
||||
CStreamBuffer m_buffer;
|
||||
bool m_closed;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user