cwThread.cpp : Fix bug where waitTimeMicrosSecs was not properly updates.

This commit is contained in:
kevin 2020-12-11 15:57:35 -05:00
parent 9e925e7996
commit e8b9771365

View File

@ -29,7 +29,7 @@ namespace cw
void* funcArg; void* funcArg;
unsigned stateMicros; unsigned stateMicros;
unsigned pauseMicros; unsigned pauseMicros;
unsigned sleepMicros = 15000; unsigned sleepMicros;
pthread_attr_t attr; pthread_attr_t attr;
} thread_t; } thread_t;
@ -50,6 +50,8 @@ namespace cw
break; break;
sleepUs( p->sleepMicros ); sleepUs( p->sleepMicros );
waitTimeMicroSecs += p->sleepMicros;
}while( waitTimeMicroSecs < p->stateMicros ); }while( waitTimeMicroSecs < p->stateMicros );
@ -133,6 +135,7 @@ cw::rc_t cw::thread::create( handle_t& hRef, cbFunc_t func, void* funcArg, int s
p->stateMicros = stateMicros; p->stateMicros = stateMicros;
p->pauseMicros = pauseMicros; p->pauseMicros = pauseMicros;
p->stateId = kPausedThId; p->stateId = kPausedThId;
p->sleepMicros = 15000;
if((sysRC = pthread_attr_init(&p->attr)) != 0) if((sysRC = pthread_attr_init(&p->attr)) != 0)
{ {