1 /*****************************************************************************/
2 /* Software Testing Automation Framework (STAF) */
3 /* (C) Copyright IBM Corp. 2001 */
4 /* */
5 /* This software is licensed under the Eclipse Public License (EPL) V1.0. */
6 /*****************************************************************************/
7
8 #ifndef STAF_MutexSemInlImpl
9 #define STAF_MutexSemInlImpl
10
11 #include "STAF.h"
12 #include "STAFMutexSem.h"
13 #include "STAFRefPtr.h"
14 #include "STAFException.h"
15
STAFMutexSem()16 STAF_INLINE STAFMutexSem::STAFMutexSem() : fMutexImpl(0)
17 {
18 unsigned int osRC = 0;
19 STAFRC_t rc = STAFMutexSemConstruct(&fMutexImpl, 0, &osRC);
20
21 STAFException::checkRC(rc, "STAFMutexSemConstruct", osRC);
22 }
23
24
request(unsigned int timeout)25 STAF_INLINE STAFRC_t STAFMutexSem::request(unsigned int timeout)
26 {
27 unsigned int osRC = 0;
28 STAFRC_t rc = STAFMutexSemRequest(fMutexImpl, timeout, &osRC);
29
30 if ((rc != kSTAFOk) && (rc != kSTAFTimeout))
31 STAFException::checkRC(rc, "STAFMutexSemRequest", osRC);
32
33 return rc;
34 }
35
36
release()37 STAF_INLINE void STAFMutexSem::release()
38 {
39 unsigned int osRC = 0;
40 STAFRC_t rc = STAFMutexSemRelease(fMutexImpl, &osRC);
41
42 STAFException::checkRC(rc, "STAFMutexSemRelease", osRC);
43 }
44
45
~STAFMutexSem()46 STAF_INLINE STAFMutexSem::~STAFMutexSem()
47 {
48 unsigned int osRC = 0;
49 STAFRC_t rc = STAFMutexSemDestruct(&fMutexImpl, &osRC);
50 }
51
52 #endif
53