mirror of
https://review.haiku-os.org/haiku
synced 2025-01-21 22:04:49 +01:00
750b92faf3
- StartMessage() can now get a size to make sure there is enough free space - if StartMessage() is called with the current message behind a certain watermark, the buffer is flushed in order to prevent moving around messages in the buffer. The actual value should be tested in real life, though. - enlarged maximum buffer size to 64k - fixed bug: could use memcpy() to move overlapping memory around - added a flag to Flush() that marks messages as needing a reply - the other way would be to mark the message "code" to contain this information Some cleanup in LinkMsgReader. BPortLink now has most methods as inlines. The buffer sizes are now declared in a shared header, so that receiver and sender are always equipped equally. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12997 a95241bf-73f2-0310-859d-f6bbb57e9c96
57 lines
1.2 KiB
C++
57 lines
1.2 KiB
C++
/*
|
|
* Copyright 2001-2005, Haiku.
|
|
* Distributed under the terms of the MIT License.
|
|
*
|
|
* Authors:
|
|
* DarkWyrm <bpmagic@columbus.rr.com>
|
|
* Pahtz <pahtz@yahoo.com.au>
|
|
*/
|
|
#ifndef _LINKMSGREADER_H
|
|
#define _LINKMSGREADER_H
|
|
|
|
#include <OS.h>
|
|
|
|
|
|
//namespace BPrivate {
|
|
|
|
class LinkMsgReader {
|
|
public:
|
|
LinkMsgReader(port_id port);
|
|
virtual ~LinkMsgReader(void);
|
|
|
|
void SetPort(port_id port);
|
|
port_id Port(void) { return fReceivePort; }
|
|
|
|
status_t GetNextMessage(int32 *code, bigtime_t timeout = B_INFINITE_TIMEOUT);
|
|
status_t Read(void *data, ssize_t size);
|
|
status_t ReadString(char **string);
|
|
template <class Type> status_t Read(Type *data)
|
|
{
|
|
return Read(data, sizeof(Type));
|
|
}
|
|
|
|
protected:
|
|
virtual status_t ReadFromPort(bigtime_t timeout);
|
|
virtual status_t AdjustReplyBuffer(bigtime_t timeout);
|
|
void ResetBuffer();
|
|
|
|
port_id fReceivePort;
|
|
|
|
char *fRecvBuffer;
|
|
|
|
int32 fRecvPosition; //current read position
|
|
|
|
int32 fRecvStart; //start of current message
|
|
|
|
int32 fRecvBufferSize;
|
|
|
|
int32 fDataSize; //size of data in recv buffer
|
|
int32 fReplySize; //size of current reply message
|
|
|
|
status_t fReadError; //Read failed for current message
|
|
};
|
|
|
|
//} // namespace BPrivate
|
|
|
|
#endif
|