1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2003 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
41 #if defined (OSG_USE_PTHREADS)
43 /*------------------------------- Semaphore --------------------------------*/
46 void PThreadSemaphoreBase::wait(void)
48 sem_wait(&(_pLowLevelSemaphore));
52 void PThreadSemaphoreBase::post(void)
54 sem_post(&(_pLowLevelSemaphore));
57 #endif /* OSG_USE_PTHREADS */
60 #if defined (OSG_USE_SPROC)
62 /*----------------------------- Semaphore-----------------------------------*/
65 void SprocSemaphoreBase::wait(void)
67 if(_pLowLevelSema != NULL)
68 uspsema(_pLowLevelSema);
72 void SprocSemaphoreBase::post(void)
74 if(_pLowLevelSema != NULL)
75 usvsema(_pLowLevelSema);
78 #endif /* OSG_USE_SPROC */
81 #if defined (OSG_USE_WINTHREADS)
83 /*------------------------------- Semaphore --------------------------------*/
86 void WinThreadSemaphoreBase::wait(void)
88 #if defined(OSG_GV_BETA) && defined(OSG_DBG_LCK)
89 fprintf(stderr, "Semaphore::acquire %p\n", this);
92 WaitForSingleObject(_pSemaphore, INFINITE);
96 void WinThreadSemaphoreBase::post(void)
98 #if defined(OSG_GV_BETA) && defined(OSG_DBG_LCK)
99 fprintf(stderr, "Semaphore::release %p\n", this);
102 ReleaseSemaphore(_pSemaphore, 1, NULL);
105 #endif /* OSG_USE_WINTHREADS */
111 Semaphore::ObjTransitPtr Semaphore::create(void)
113 return Semaphore::get(NULL, false);
117 const MPSemaphoreType &Semaphore::getClassType(void)
122 /*----------------------------- Semaphore ----------------------------------*/
125 void Semaphore::wait(void)
131 void Semaphore::post(void)