Skip to content

Commit

Permalink
fix timer wait, it may interrupt
Browse files Browse the repository at this point in the history
  • Loading branch information
absolute8511 committed Jan 26, 2015
1 parent a274ca0 commit 8540a01
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Core/timer_thread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace threadpool
struct timeval waited;
timersub(&end, &start,&waited);
unsigned waitmsec = waited.tv_sec*1000 + waited.tv_usec/1000;
printf("wait wrong,waited only %d ms.\n",waitmsec);
//printf("wait wrong,waited only %d ms.\n",waitmsec);
if(waitmsec<msec)
return msec-waitmsec;
return 0;
Expand All @@ -65,7 +65,10 @@ namespace threadpool
if(m_tpool->getterminate())
return false;

wait(1000);
int waitms = 1000;
while(waitms > 0) {
waitms = wait(waitms);
}
if(m_tpool->getterminate())
return false;
//printf("timer proc in thread: %lu.\n",(unsigned long)pthread_self());
Expand Down

0 comments on commit 8540a01

Please sign in to comment.