root/OpenSceneGraph/trunk/include/OpenThreads/Mutex @ 13041

Revision 13041, 2.0 kB (checked in by robert, 3 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/* -*-c++-*- OpenThreads library, Copyright (C) 2002 - 2007  The Open Thread Group
2 *
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.
7 *
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.
12*/
13
14
15//
16// Mutex - C++ mutex class
17// ~~~~~
18//
19
20#ifndef _OPENTHREADS_MUTEX_
21#define _OPENTHREADS_MUTEX_
22
23#include <OpenThreads/Exports>
24
25namespace OpenThreads {
26
27/**
28 *  @class Mutex
29 *  @brief  This class provides an object-oriented thread mutex interface.
30 */
31class OPENTHREAD_EXPORT_DIRECTIVE Mutex {
32
33    friend class Condition;
34
35public:
36
37    enum MutexType
38    {
39        MUTEX_NORMAL,
40        MUTEX_RECURSIVE
41    };
42
43    /**
44     *  Constructor
45     */
46    Mutex(MutexType type=MUTEX_NORMAL);
47
48    /**
49     *  Destructor
50     */
51    virtual ~Mutex();
52
53
54    MutexType getMutexType() const { return _mutexType; }
55
56
57    /**
58     *  Lock the mutex
59     *
60     *  @return 0 if normal, -1 if errno set, errno code otherwise.
61     */
62    virtual int lock();
63
64    /**
65     *  Unlock the mutex
66     *
67     *  @return 0 if normal, -1 if errno set, errno code otherwise.
68     */
69    virtual int unlock();
70
71    /**
72     *  Test if mutex can be locked.
73     *
74     *  @return 0 if normal, -1 if errno set, errno code otherwise.
75     */
76    virtual int trylock();
77
78private:
79
80    /**
81     *  Private copy constructor, to prevent tampering.
82     */
83    Mutex(const Mutex &/*m*/) {};
84
85    /**
86     *  Private copy assignment, to prevent tampering.
87     */
88    Mutex &operator=(const Mutex &/*m*/) {return *(this);};
89
90    /**
91     *  Implementation-specific private data.
92     */
93    void *_prvData;
94    MutexType _mutexType;
95
96};
97
98}
99
100#endif // _OPENTHREADS_MUTEX_
Note: See TracBrowser for help on using the browser.