#4740 Used global const rather than macro

This commit is contained in:
Xinyu Hou 2016-09-13 11:09:47 -04:00 committed by Andrew Nelless
parent 8ab69a22ae
commit d8ace7fb4a
1 changed files with 7 additions and 6 deletions

View File

@ -35,8 +35,9 @@
using namespace std; using namespace std;
#define FAKE_HEARTBEAT_THRESHOLD 3
#define CHUNK_SIZE 512 * 1024; // 512kb static const double g_fakeHeartbeatThreshold = 3;
static const size_t g_chunkSize = 512 * 1024; //512kb
bool StreamChunker::s_isChunkingFile = false; bool StreamChunker::s_isChunkingFile = false;
bool StreamChunker::s_interruptFile = false; bool StreamChunker::s_interruptFile = false;
@ -68,7 +69,7 @@ StreamChunker::sendFile(
// send chunk messages with a fixed chunk size // send chunk messages with a fixed chunk size
size_t sentLength = 0; size_t sentLength = 0;
size_t chunkSize = CHUNK_SIZE; size_t chunkSize = g_chunkSize;
Stopwatch fakeHeartbeatStopwatch; Stopwatch fakeHeartbeatStopwatch;
fakeHeartbeatStopwatch.start(); fakeHeartbeatStopwatch.start();
file.seekg (0, std::ios::beg); file.seekg (0, std::ios::beg);
@ -80,7 +81,7 @@ StreamChunker::sendFile(
break; break;
} }
if (fakeHeartbeatStopwatch.getTime() > FAKE_HEARTBEAT_THRESHOLD) { if (fakeHeartbeatStopwatch.getTime() > g_fakeHeartbeatThreshold) {
events->addEvent(Event(events->forFile().keepAlive(), eventTarget)); events->addEvent(Event(events->forFile().keepAlive(), eventTarget));
fakeHeartbeatStopwatch.reset(); fakeHeartbeatStopwatch.reset();
} }
@ -133,12 +134,12 @@ StreamChunker::sendClipboard(
// send clipboard chunk with a fixed size // send clipboard chunk with a fixed size
size_t sentLength = 0; size_t sentLength = 0;
size_t chunkSize = CHUNK_SIZE; size_t chunkSize = g_chunkSize;
Stopwatch fakeHeartbeatStopwatch; Stopwatch fakeHeartbeatStopwatch;
fakeHeartbeatStopwatch.start(); fakeHeartbeatStopwatch.start();
while (true) { while (true) {
if (fakeHeartbeatStopwatch.getTime() > FAKE_HEARTBEAT_THRESHOLD) { if (fakeHeartbeatStopwatch.getTime() > g_fakeHeartbeatThreshold) {
events->addEvent(Event(events->forFile().keepAlive(), eventTarget)); events->addEvent(Event(events->forFile().keepAlive(), eventTarget));
fakeHeartbeatStopwatch.reset(); fakeHeartbeatStopwatch.reset();
} }