installed
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
|
||||
#include "osiSem.h"
|
||||
#include "shareLib.h"
|
||||
|
||||
class epicsShareClass osiEvent {
|
||||
public:
|
||||
osiEvent ();
|
||||
~osiEvent ();
|
||||
void signal ();
|
||||
void wait (); /* blocks until full */
|
||||
bool wait (double timeOut); /* false if empty at time out */
|
||||
bool tryWait (); /* false if empty */
|
||||
void show (unsigned level);
|
||||
|
||||
class invalidSemaphore {}; /* exception */
|
||||
class noMemory {}; /* exception */
|
||||
private:
|
||||
semBinaryId id;
|
||||
};
|
||||
|
||||
inline osiEvent::osiEvent ()
|
||||
{
|
||||
this->id = semBinaryCreate (semEmpty);
|
||||
if (this->id==0) {
|
||||
# ifdef noExceptionsFromCXX
|
||||
assert (0);
|
||||
# else
|
||||
throw noMemory ();
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
inline osiEvent::~osiEvent ()
|
||||
{
|
||||
semBinaryDestroy (this->id);
|
||||
}
|
||||
|
||||
inline void osiEvent::signal ()
|
||||
{
|
||||
semBinaryGive (this->id);
|
||||
}
|
||||
|
||||
inline void osiEvent::wait ()
|
||||
{
|
||||
semTakeStatus status;
|
||||
status = semBinaryTake (this->id);
|
||||
if (status!=semTakeOK) {
|
||||
# ifdef noExceptionsFromCXX
|
||||
assert (0);
|
||||
# else
|
||||
throw invalidSemaphore ();
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
inline bool osiEvent::wait (double timeOut)
|
||||
{
|
||||
semTakeStatus status;
|
||||
status = semBinaryTakeTimeout (this->id, timeOut);
|
||||
if (status==semTakeOK) {
|
||||
return true;
|
||||
}
|
||||
else if (status==semTakeTimeout) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
# ifdef noExceptionsFromCXX
|
||||
assert (0);
|
||||
# else
|
||||
throw invalidSemaphore ();
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
inline bool osiEvent::tryWait ()
|
||||
{
|
||||
semTakeStatus status;
|
||||
status = semBinaryTakeNoWait (this->id);
|
||||
if (status==semTakeOK) {
|
||||
return true;
|
||||
}
|
||||
else if (status==semTakeTimeout) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
# ifdef noExceptionsFromCXX
|
||||
assert (0);
|
||||
# else
|
||||
throw invalidSemaphore ();
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
inline void osiEvent::show (unsigned level)
|
||||
{
|
||||
semBinaryShow (this->id, level);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
|
||||
#include "osiSem.h"
|
||||
#include "shareLib.h"
|
||||
|
||||
class epicsShareClass osiMutex {
|
||||
public:
|
||||
osiMutex ();
|
||||
~osiMutex ();
|
||||
void lock () const; /* blocks until success */
|
||||
bool lock (double timeOut) const; /* true if successful */
|
||||
bool tryLock () const; /* true if successful */
|
||||
void unlock () const;
|
||||
void show (unsigned level) const;
|
||||
|
||||
class invalidSemaphore {}; /* exception */
|
||||
class noMemory {}; /* exception */
|
||||
private:
|
||||
mutable semMutexId id;
|
||||
};
|
||||
|
||||
inline osiMutex::osiMutex ()
|
||||
{
|
||||
this->id = semMutexCreate ();
|
||||
if (this->id==0) {
|
||||
# ifdef noExceptionsFromCXX
|
||||
assert (0);
|
||||
# else
|
||||
throw noMemory ();
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
inline osiMutex::~osiMutex ()
|
||||
{
|
||||
semMutexDestroy (this->id);
|
||||
}
|
||||
|
||||
inline void osiMutex::lock () const
|
||||
{
|
||||
semTakeStatus status;
|
||||
status = semMutexTake (this->id);
|
||||
if (status!=semTakeOK) {
|
||||
# ifdef noExceptionsFromCXX
|
||||
assert (0);
|
||||
# else
|
||||
throw invalidSemaphore ();
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
inline bool osiMutex::lock (double timeOut) const
|
||||
{
|
||||
semTakeStatus status;
|
||||
status = semMutexTakeTimeout (this->id, timeOut);
|
||||
if (status==semTakeOK) {
|
||||
return true;
|
||||
}
|
||||
else if (status==semTakeTimeout) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
# ifdef noExceptionsFromCXX
|
||||
assert (0);
|
||||
# else
|
||||
throw invalidSemaphore ();
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
inline bool osiMutex::tryLock () const
|
||||
{
|
||||
semTakeStatus status;
|
||||
status = semMutexTakeNoWait (this->id);
|
||||
if (status==semTakeOK) {
|
||||
return true;
|
||||
}
|
||||
else if (status==semTakeTimeout) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
# ifdef noExceptionsFromCXX
|
||||
assert (0);
|
||||
# else
|
||||
throw invalidSemaphore ();
|
||||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
inline void osiMutex::unlock () const
|
||||
{
|
||||
semMutexGive (this->id);
|
||||
}
|
||||
|
||||
inline void osiMutex::show (unsigned level) const
|
||||
{
|
||||
semMutexShow (this->id, level);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// Author: Jeff Hill
|
||||
//
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "osiThread.h"
|
||||
|
||||
static void osiThreadCallEntryPoint (void *pPvt)
|
||||
{
|
||||
osiThread *pThread = static_cast<osiThread *> (pPvt);
|
||||
pThread->entryPoint ();
|
||||
}
|
||||
|
||||
osiThread::osiThread (const char *name, unsigned stackSize,
|
||||
unsigned priority)
|
||||
{
|
||||
this->id = threadCreate (name, priority, stackSize,
|
||||
osiThreadCallEntryPoint, static_cast <void *> (this) );
|
||||
}
|
||||
Reference in New Issue
Block a user