From 43822c9e35fb65ce3fed2f7f5e87b67418dee6eb Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Thu, 11 Jan 2001 22:07:17 +0000 Subject: [PATCH] accomodate Marty's osi => epics name changes --- src/libCom/osi/osiEvent.h | 101 -------------------------------- src/libCom/osi/osiMutex.h | 118 -------------------------------------- 2 files changed, 219 deletions(-) delete mode 100644 src/libCom/osi/osiEvent.h delete mode 100644 src/libCom/osi/osiMutex.h diff --git a/src/libCom/osi/osiEvent.h b/src/libCom/osi/osiEvent.h deleted file mode 100644 index 1cec8c13c..000000000 --- a/src/libCom/osi/osiEvent.h +++ /dev/null @@ -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 */ - - diff --git a/src/libCom/osi/osiMutex.h b/src/libCom/osi/osiMutex.h deleted file mode 100644 index 2cbba7087..000000000 --- a/src/libCom/osi/osiMutex.h +++ /dev/null @@ -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 */