fixed startup order problems without impactiing the structure of the

design
This commit is contained in:
Jeff Hill
2000-05-24 22:07:10 +00:00
parent 5040152dc9
commit 15fca75a88
2 changed files with 25 additions and 15 deletions
+20 -12
View File
@@ -7,34 +7,42 @@
#include <stdio.h>
#include <stddef.h>
static void osiThreadCallEntryPoint (void *pPvt); // for gnu warning
static void osiThreadCallEntryPoint ( void *pPvt ); // for gnu warning
#define epicsExportSharedSymbols
#include "osiThread.h"
static void osiThreadCallEntryPoint (void *pPvt)
static void osiThreadCallEntryPoint ( void *pPvt )
{
osiThread *pThread = static_cast<osiThread *> (pPvt);
pThread->entryPoint ();
osiThread *pThread = static_cast <osiThread *> ( pPvt );
pThread->begin.wait ();
if ( ! pThread->cancel ) {
pThread->entryPoint ();
}
pThread->exit.signal ();
}
osiThread::osiThread () : id(0), exit()
osiThread::osiThread ( const char *name, unsigned stackSize, unsigned priority ) :
cancel (false)
{
this->id = threadCreate ( name, priority, stackSize,
osiThreadCallEntryPoint, static_cast <void *> (this) );
}
osiThread::~osiThread ()
{
while ( !this->exit.wait (5.0) ) {
printf ("osiThread::~osiThread ():"
" Warning, thread object destroyed before thread exit \n");
if ( this->id ) {
this->cancel = true;
this->begin.signal ();
while ( ! this->exit.wait ( 5.0 ) ) {
printf ("osiThread::~osiThread ():"
" Warning, thread object destroyed before thread exit \n");
}
}
}
void osiThread::start(const char *name, unsigned stackSize, unsigned priority)
void osiThread::start ()
{
id = threadCreate (name, priority, stackSize,
osiThreadCallEntryPoint, static_cast <void *> (this) );
this->begin.signal ();
}
+5 -3
View File
@@ -99,11 +99,11 @@ epicsShareFunc void * epicsShareAPI threadPrivateGet (threadPrivateId);
class epicsShareClass osiThread {
public:
osiThread();
osiThread (const char *name, unsigned stackSize,
unsigned priority=threadPriorityLow);
virtual ~osiThread ();
void start(const char *name, unsigned stackSize,
unsigned priority=threadPriorityLow);
void start();
virtual void entryPoint () = 0;
@@ -124,6 +124,8 @@ public:
private:
threadId id;
osiEvent exit;
osiEvent begin;
bool cancel;
friend void osiThreadCallEntryPoint (void *pPvt);
};