mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Use max block size when reading from socket
This commit is contained in:
parent
e5712e9809
commit
0f8b844873
@ -146,7 +146,7 @@ public:
|
||||
socketStream << timestepByteCount ;
|
||||
|
||||
// Then write the data.
|
||||
size_t valueCount = RiaSocketDataTransfer::doubleValueCountInBlock();
|
||||
size_t valueCount = RiaSocketDataTransfer::maximumValueCountInBlock();
|
||||
std::vector<double> values(valueCount);
|
||||
size_t valueIndex = 0;
|
||||
|
||||
@ -315,7 +315,7 @@ public:
|
||||
continue;
|
||||
}
|
||||
|
||||
size_t valueCount = RiaSocketDataTransfer::doubleValueCountInBlock();
|
||||
size_t valueCount = RiaSocketDataTransfer::maximumValueCountInBlock();
|
||||
std::vector<double> values(valueCount);
|
||||
size_t valueIndex = 0;
|
||||
for (size_t cellIdx = 0; cellIdx < rigGrid->cellCount(); cellIdx++)
|
||||
|
@ -27,7 +27,7 @@ bool RiaSocketDataTransfer::writeBlockDataToSocket(QTcpSocket* socket, const cha
|
||||
quint64 bytesWritten = 0;
|
||||
int blockCount = 0;
|
||||
|
||||
quint64 maxBlockSize = doubleValueCountInBlock() * sizeof(double);
|
||||
quint64 maxBlockSize = maximumValueCountInBlock() * sizeof(double);
|
||||
|
||||
while (bytesWritten < bytesToWrite)
|
||||
{
|
||||
@ -57,11 +57,14 @@ bool RiaSocketDataTransfer::readBlockDataFromSocket(QTcpSocket* socket, char* da
|
||||
{
|
||||
quint64 bytesRead = 0;
|
||||
|
||||
quint64 maxBlockSize = maximumValueCountInBlock() * sizeof(double);
|
||||
|
||||
while (bytesRead < bytesToRead)
|
||||
{
|
||||
if (socket->bytesAvailable())
|
||||
{
|
||||
quint64 byteCountToRead = bytesToRead - bytesRead;
|
||||
byteCountToRead = qMin(byteCountToRead, maxBlockSize);
|
||||
|
||||
qint64 actuallyBytesRead = socket->read(data + bytesRead, byteCountToRead);
|
||||
if (actuallyBytesRead < 0)
|
||||
@ -73,6 +76,10 @@ bool RiaSocketDataTransfer::readBlockDataFromSocket(QTcpSocket* socket, char* da
|
||||
}
|
||||
|
||||
bytesRead += actuallyBytesRead;
|
||||
|
||||
#ifdef octave_oct_h
|
||||
//octave_stdout << "Byte read " << bytesRead << " of a total of "<< bytesToRead << "\n";
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -85,7 +92,7 @@ bool RiaSocketDataTransfer::readBlockDataFromSocket(QTcpSocket* socket, char* da
|
||||
}
|
||||
}
|
||||
|
||||
// Allow Octave process to end a long running Octave function
|
||||
// Allow Octave process to end a long running Octave function
|
||||
#ifdef octave_oct_h
|
||||
OCTAVE_QUIT;
|
||||
#endif
|
||||
@ -98,8 +105,9 @@ bool RiaSocketDataTransfer::readBlockDataFromSocket(QTcpSocket* socket, char* da
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t RiaSocketDataTransfer::doubleValueCountInBlock()
|
||||
size_t RiaSocketDataTransfer::maximumValueCountInBlock()
|
||||
{
|
||||
return 2000;
|
||||
return 20000;
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
class RiaSocketDataTransfer
|
||||
{
|
||||
public:
|
||||
static size_t doubleValueCountInBlock();
|
||||
static size_t maximumValueCountInBlock();
|
||||
|
||||
public:
|
||||
static bool writeBlockDataToSocket(QTcpSocket* socket, const char* data, quint64 bytesToWrite, QStringList& errorMessages);
|
||||
|
Loading…
Reference in New Issue
Block a user