accomodate Marty's osi => epics name changes

This commit is contained in:
Jeff Hill
2001-01-11 22:07:17 +00:00
parent 8dd2439e65
commit 43822c9e35
2 changed files with 0 additions and 219 deletions

View File

@@ -1,101 +0,0 @@
/*
* $Id$
*
*
* Author: Jeff Hill
*
*/
#ifndef osiEventh
#define osiEventh
#include "locationException.h"
#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 ) const;
class invalidSemaphore {}; /* exception */
class noMemory {}; /* exception */
private:
osiEvent ( const osiEvent & );
osiEvent & operator = ( const osiEvent & );
semBinaryId id;
};
inline osiEvent::osiEvent () :
id ( semBinaryCreate (semEmpty) )
{
if ( this->id == 0 ) {
throwWithLocation ( noMemory () );
}
}
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) {
throwWithLocation ( invalidSemaphore () );
}
}
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 {
throwWithLocation ( invalidSemaphore () );
return false;
}
}
inline bool osiEvent::tryWait ()
{
semTakeStatus status;
status = semBinaryTakeNoWait (this->id);
if (status==semTakeOK) {
return true;
}
else if (status==semTakeTimeout) {
return false;
}
else {
throwWithLocation ( invalidSemaphore () );
return false;
}
}
inline void osiEvent::show ( unsigned level ) const
{
semBinaryShow ( this->id, level );
}
#endif /* osiEventh */

View File

@@ -1,118 +0,0 @@
/*
* $Id$
*
*
* Author: Jeff Hill
*
*/
#ifndef osiMutexh
#define osiMutexh
#include "locationException.h"
#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;
};
// Automatically applies and releases the mutex.
// This is for use in situations where C++ exceptions are possible.
class osiAutoMutex {
public:
osiAutoMutex ( osiMutex & );
~osiAutoMutex ();
private:
osiMutex &mutex;
};
inline osiMutex::osiMutex ()
{
this->id = semMutexCreate ();
if (this->id==0) {
throwWithLocation ( noMemory () );
}
}
inline osiMutex::~osiMutex ()
{
semMutexDestroy (this->id);
}
inline void osiMutex::lock () const
{
semTakeStatus status;
status = semMutexTake (this->id);
if (status!=semTakeOK) {
throwWithLocation ( invalidSemaphore () );
}
}
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 {
throwWithLocation ( invalidSemaphore () );
return false; // never here, compiler is happy
}
}
inline bool osiMutex::tryLock () const
{
semTakeStatus status;
status = semMutexTakeNoWait (this->id);
if (status==semTakeOK) {
return true;
}
else if (status==semTakeTimeout) {
return false;
}
else {
throwWithLocation ( invalidSemaphore () );
return false; // never here, but compiler is happy
}
}
inline void osiMutex::unlock () const
{
semMutexGive (this->id);
}
inline void osiMutex::show (unsigned level) const
{
semMutexShow (this->id, level);
}
inline osiAutoMutex::osiAutoMutex ( osiMutex &mutexIn ) :
mutex ( mutexIn )
{
this->mutex.lock ();
}
inline osiAutoMutex::~osiAutoMutex ()
{
this->mutex.unlock ();
}
#endif /* osiMutexh */