Skip to content

Commit 4c0fe27

Browse files
committed
add sleep to reduce CPU loading
1 parent 1e4fe65 commit 4c0fe27

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ typedef unsigned char uint8;
2727
static const int PACK_NUM_LIMIT = 1000000;
2828

2929
// how many reads one pack has
30-
static const int PACK_SIZE = 1000;
30+
static const int PACK_SIZE = 10000;
3131

3232
// if one pack is produced, but not consumed, it will be kept in the memory
3333
// this number limit the number of in memory packs

src/threadconfig.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "threadconfig.h"
22
#include "util.h"
33
#include <memory.h>
4+
#include <unistd.h>
45

56
ThreadConfig::ThreadConfig(Options* opt, int threadId){
67
mOptions = opt;
@@ -42,6 +43,9 @@ bool ThreadConfig::setInputCompleted() {
4243
}
4344

4445
void ThreadConfig::output(){
46+
if(mOutputCounter >= mInputCounter) {
47+
usleep(100);
48+
}
4549
while( mOutputCounter < mInputCounter)
4650
{
4751
long target = mOutputCounter % PACK_NUM_LIMIT;

0 commit comments

Comments
 (0)