1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Buffer data from recv() calls.

This reduces cost of socket reads measured in a test run from 47ms to
8.7ms.
This commit is contained in:
Bartosz Taudul
2018-07-15 19:34:47 +02:00
parent c6ea032de3
commit ea4470b26e
2 changed files with 48 additions and 2 deletions
+9 -1
View File
@@ -10,6 +10,8 @@ namespace tracy
class Socket
{
enum { BufSize = 128 * 1024 };
public:
Socket();
Socket( int sock );
@@ -19,7 +21,6 @@ public:
void Close();
int Send( const void* buf, int len );
int Recv( void* buf, int len, const timeval* tv );
bool Read( void* buf, int len, const timeval* tv, std::function<bool()> exitCb );
bool HasData();
@@ -30,7 +31,14 @@ public:
Socket& operator=( Socket&& ) = delete;
private:
int RecvBuffered( void* buf, int len, const timeval* tv );
int Recv( void* buf, int len, const timeval* tv );
int m_sock;
char* m_buf;
char* m_bufPtr;
int m_bufLeft;
};
class ListenSocket