barrier/synergy/CInputPacketStream.h

38 lines
813 B
C
Raw Normal View History

2001-10-06 18:13:28 +04:00
#ifndef CINPUTPACKETSTREAM_H
#define CINPUTPACKETSTREAM_H
#include "CInputStreamFilter.h"
#include "CBufferedInputStream.h"
#include "CMutex.h"
class CInputPacketStream : public CInputStreamFilter {
2002-04-29 18:40:01 +04:00
public:
2001-10-06 18:13:28 +04:00
CInputPacketStream(IInputStream*, bool adoptStream = true);
~CInputPacketStream();
// manipulators
// accessors
// IInputStream overrides
virtual void close();
virtual UInt32 read(void*, UInt32 maxCount, double timeout);
virtual UInt32 getSize() const;
2001-10-06 18:13:28 +04:00
2002-04-29 18:40:01 +04:00
private:
enum EResult { kData, kHungup, kTimedout };
UInt32 getSizeNoLock() const;
EResult waitForFullMessage(double timeout) const;
EResult getMoreMessage(double timeout) const;
bool hasFullMessage() const;
2001-10-06 18:13:28 +04:00
2002-04-29 18:40:01 +04:00
private:
2001-10-06 18:13:28 +04:00
CMutex m_mutex;
mutable UInt32 m_size;
mutable CBufferedInputStream m_buffer;
};
#endif