// // $Id$ // // Author: Jeff Hill // #include #include extern "C" { static void epicsThreadCallEntryPoint ( void *pPvt ); // for gnu warning } #define epicsExportSharedSymbols #include "epicsThread.h" void epicsThreadRunable::stop() {}; static void epicsThreadCallEntryPoint ( void *pPvt ) { epicsThread *pThread = static_cast ( pPvt ); pThread->begin.wait (); if ( ! pThread->cancel ) { pThread->runable.run (); } pThread->id = 0; pThread->exit.signal (); } epicsThread::epicsThread (epicsThreadRunable &r, const char *name, unsigned stackSize, unsigned priority ) : runable(r), cancel (false) { this->id = epicsThreadCreate ( name, priority, stackSize, epicsThreadCallEntryPoint, static_cast (this) ); } epicsThread::~epicsThread () { if ( this->id ) { this->cancel = true; this->begin.signal (); while ( ! this->exit.wait ( 5.0 ) ) { printf ("epicsThread::~epicsThread ():" " Warning, thread object destroyed before thread exit \n"); } } } void epicsThread::start () { this->begin.signal (); } bool epicsThread::isCurrentThread () const { return ( epicsThreadGetIdSelf () == this->id ); }