1/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007 The Open Thread Group
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
16// Mutex - C++ mutex class
20#ifndef _OPENTHREADS_MUTEX_
21#define _OPENTHREADS_MUTEX_
23#include <OpenThreads/Exports>
25namespace OpenThreads {
29 * @brief This class provides an object-oriented thread mutex interface.
31class OPENTHREAD_EXPORT_DIRECTIVE Mutex {
33 friend class Condition;
46 Mutex(MutexType type=MUTEX_NORMAL);
54 MutexType getMutexType() const { return _mutexType; }
60 * @return 0 if normal, -1 if errno set, errno code otherwise.
67 * @return 0 if normal, -1 if errno set, errno code otherwise.
72 * Test if mutex can be locked.
74 * @return 0 if normal, -1 if errno set, errno code otherwise.
76 virtual int trylock();
81 * Private copy constructor, to prevent tampering.
83 Mutex(const Mutex &/*m*/) {};
86 * Private copy assignment, to prevent tampering.
88 Mutex &operator=(const Mutex &/*m*/) {return *(this);};
91 * Implementation-specific private data.
100#endif // _OPENTHREADS_MUTEX_