class epicsThread is joinable
This commit is contained in:
@@ -153,6 +153,10 @@ bool epicsThread::exitWait ( const double delay ) throw ()
|
||||
if ( this->pThreadDestroyed ) {
|
||||
*this->pThreadDestroyed = true;
|
||||
}
|
||||
if(!joined) {
|
||||
epicsThreadJoin(this->id);
|
||||
joined = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
epicsTime exitWaitBegin = epicsTime::getCurrent ();
|
||||
@@ -166,6 +170,10 @@ bool epicsThread::exitWait ( const double delay ) throw ()
|
||||
epicsTime current = epicsTime::getCurrent ();
|
||||
exitWaitElapsed = current - exitWaitBegin;
|
||||
}
|
||||
if(!joined) {
|
||||
epicsThreadJoin(this->id);
|
||||
joined = true;
|
||||
}
|
||||
}
|
||||
catch ( std :: exception & except ) {
|
||||
errlogPrintf (
|
||||
@@ -190,10 +198,18 @@ epicsThread::epicsThread (
|
||||
unsigned stackSize, unsigned priority ) :
|
||||
runable ( runableIn ), id ( 0 ), pThreadDestroyed ( 0 ),
|
||||
begin ( false ), cancel ( false ), terminated ( false )
|
||||
, joined(false)
|
||||
{
|
||||
this->id = epicsThreadCreate (
|
||||
pName, priority, stackSize, epicsThreadCallEntryPoint,
|
||||
static_cast < void * > ( this ) );
|
||||
epicsThreadOpts opts;
|
||||
epicsThreadOptsDefaults(&opts);
|
||||
opts.stackSize = stackSize;
|
||||
opts.priority = priority;
|
||||
opts.joinable = 1;
|
||||
|
||||
this->id = epicsThreadCreateOpt(
|
||||
pName, epicsThreadCallEntryPoint,
|
||||
static_cast < void * > ( this ),
|
||||
&opts);
|
||||
if ( ! this->id ) {
|
||||
throw unableToCreateThread ();
|
||||
}
|
||||
|
||||
@@ -197,6 +197,7 @@ private:
|
||||
bool begin;
|
||||
bool cancel;
|
||||
bool terminated;
|
||||
bool joined;
|
||||
|
||||
bool beginWait () throw ();
|
||||
epicsThread ( const epicsThread & );
|
||||
|
||||
Reference in New Issue
Block a user