changed: gcc8 base update
[opensg.git] / Source / Base / Threading / OSGLockPolicies.inl
blobc081d0c9366e31c3d49fda9041ef3841a2b6bc19
1 /*---------------------------------------------------------------------------*\
2  *                                OpenSG                                     *
3  *                                                                           *
4  *                                                                           *
5  *             Copyright (C) 2000-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
42 /*-------------------------------------------------------------------------*/
43 /*                             Destructor                                  */
45 inline
46 NoLockPolicy::NoLockPolicy(void)
51 inline
52 NoLockPolicy::~NoLockPolicy(void)
56 /*-------------------------------------------------------------------------*/
57 /*                        Reference Counting                               */
59 inline
60 void NoLockPolicy::acquire(void)
64 inline
65 void NoLockPolicy::release(void)
69 inline
70 bool NoLockPolicy::request(void)
72     return true;
77 /*-------------------------------------------------------------------------*/
78 /*                            Constructors                                 */
81 inline
82 SingleLockPolicy::SingleLockPolicy(void) :
83     _pLock(NULL)
85     _pLock = Lock::create();
89 inline
90 SingleLockPolicy::~SingleLockPolicy(void)
92     _pLock = NULL;
95 inline
96 void SingleLockPolicy::acquire(void)
98     _pLock->acquire();
101 inline
102 void SingleLockPolicy::release(void)
104     _pLock->release();
107 inline
108 bool SingleLockPolicy::request(void)
110     return _pLock->request();
115 /*-------------------------------------------------------------------------*/
116 /*                            Constructors                                 */
119 inline
120 SingleStaticInitLockPolicy::SingleStaticInitLockPolicy(void) :
121     _pLock(NULL)
123     addPreFactoryInitFunction(
124         boost::bind(&SingleStaticInitLockPolicy::init, this));
126     addPreMPExitFunction(
127         boost::bind(&SingleStaticInitLockPolicy::shutdown, this));
131 inline
132 SingleStaticInitLockPolicy::~SingleStaticInitLockPolicy(void)
136 inline
137 bool SingleStaticInitLockPolicy::init(void)
139     _pLock = Lock::create();
141     return true;
144 inline
145 bool SingleStaticInitLockPolicy::shutdown(void)
147     _pLock = NULL;
149     return true;
152 inline
153 void SingleStaticInitLockPolicy::acquire(void)
155     _pLock->acquire();
158 inline
159 void SingleStaticInitLockPolicy::release(void)
161     _pLock->release();
164 inline
165 bool SingleStaticInitLockPolicy::request(void)
167     return _pLock->request();
170 OSG_END_NAMESPACE