changed: auto add updateData callback to stages so that stagedata can be updated...
[opensg.git] / Source / Base / Threading / OSGSemaphore.inl
blob9b8a8934e81d8856d7e6cb0c1af3a663c0290bd5
1 /*---------------------------------------------------------------------------*\
2  *                                OpenSG                                     *
3  *                                                                           *
4  *                                                                           *
5  *           Copyright (C) 2003 by the OpenSG Forum                          *
6  *                                                                           *
7  *                            www.opensg.org                                 *
8  *                                                                           *
9  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
10  *                                                                           *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13  *                                License                                    *
14  *                                                                           *
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.                               *
18  *                                                                           *
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.                          *
23  *                                                                           *
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.                 *
27  *                                                                           *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30  *                                Changes                                    *
31  *                                                                           *
32  *                                                                           *
33  *                                                                           *
34  *                                                                           *
35  *                                                                           *
36  *                                                                           *
37 \*---------------------------------------------------------------------------*/
39 OSG_BEGIN_NAMESPACE
41 #if defined (OSG_USE_PTHREADS)
43 /*------------------------------- Semaphore --------------------------------*/
45 inline
46 void PThreadSemaphoreBase::wait(void)
48     sem_wait(&(_pLowLevelSemaphore));
51 inline
52 void PThreadSemaphoreBase::post(void)
54     sem_post(&(_pLowLevelSemaphore));
57 #endif /* OSG_USE_PTHREADS */
60 #if defined (OSG_USE_SPROC)
62 /*----------------------------- Semaphore-----------------------------------*/
64 inline
65 void SprocSemaphoreBase::wait(void)
67     if(_pLowLevelSema != NULL)
68         uspsema(_pLowLevelSema);
71 inline
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 --------------------------------*/
85 inline
86 void WinThreadSemaphoreBase::wait(void)
88 #if defined(OSG_GV_BETA) && defined(OSG_DBG_LCK)
89     fprintf(stderr, "Semaphore::acquire %p\n", this);
90 #endif
92     WaitForSingleObject(_pSemaphore, INFINITE);
95 inline
96 void WinThreadSemaphoreBase::post(void)
98 #if defined(OSG_GV_BETA) && defined(OSG_DBG_LCK)
99     fprintf(stderr, "Semaphore::release %p\n", this);
100 #endif
102     ReleaseSemaphore(_pSemaphore, 1, NULL);
105 #endif /* OSG_USE_WINTHREADS */
110 inline
111 Semaphore::ObjTransitPtr Semaphore::create(void)
113     return Semaphore::get(NULL, false);
116 inline
117 const MPSemaphoreType &Semaphore::getClassType(void)
119     return _type;
122 /*----------------------------- Semaphore ----------------------------------*/
124 inline
125 void Semaphore::wait(void)
127     Inherited::wait();
130 inline
131 void Semaphore::post(void)
133     Inherited::post();
136 OSG_END_NAMESPACE