changed attributes of header files
[platform/core/location/maps-plugin-here.git] / inc / engine / common / Mutex.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file                FBaseRtMutex.h
19  * @brief               This is the header file for the %Mutex class.
20  *
21  * This header file contains the declarations of the %Mutex class.
22  */
23
24 #ifndef _TIZEN_MAPS_MUTEX_H_
25 #define _TIZEN_MAPS_MUTEX_H_
26
27
28 #include "HereMaps_global.h"
29 #include "base/BaseObject.h"
30
31
32 TIZEN_MAPS_BEGIN_NAMESPACE
33
34
35 class Mutex
36         : public Tizen::Maps::Object
37 {
38 public:
39         /**
40          *      This is the default constructor for this class.
41          *
42          *      @since 2.0
43          *      @remarks        After creating an instance of this class, you must explicitly call one of
44          *                              the Create() methods to initialize the instance.
45          */
46         Mutex(void);
47
48         /**
49          *      This is the destructor for this class.
50          *
51          *      @since 2.0
52          */
53         virtual ~Mutex(void);
54
55         /**
56          *      Creates an unnamed Mutex.
57          *
58          *      @since 2.0
59          *      @return                 An error code
60          *      @exception      E_SUCCESS               The method was successful.
61          *      @exception      E_SYSTEM                An unknown operating system error occurred.
62          */
63         result Create(void);
64
65         /**
66          *      Creates a non-recursive mutex.
67          *
68          *      @since 2.0
69          *      @return                 An error code
70          *      @exception      E_SUCCESS               The method was successful.
71          *      @exception      E_SYSTEM                An unknown operating system error occurred.
72          */
73         result CreateNonRecursiveMutex(void);
74
75         /**
76          *      Creates a named Mutex. @n
77          *      If there is already a Mutex with the specified name, this creates a Mutex which references that particular Mutex.
78          *
79          *      @since 2.0
80          *      @return                 An error code
81          *      @param[in]      name                    The name of the Mutex
82          *      @exception      E_SUCCESS               The method was successful.
83          *      @exception      E_SYSTEM                An unknown operating system error occurred.
84          */
85         result Create(const String& name);
86
87         /**
88          *      Acquires the Mutex if it is not acquired. @n
89          *      If the Mutex is already acquired by another thread,
90          *      the current thread is blocked until the Mutex is released.
91          *
92          *      @since 2.0
93          *      @return                 An error code
94          *      @param[in]      timeout                 The period during which the thread tries to acquire the mutex
95          *      @exception      E_SUCCESS               The method was successful.
96          *      @exception      E_TIMEOUT               The operation could not be completed within the specified time period. @n
97          *      @exception      E_SYSTEM                An unknown operating system error occurred. @n
98          *                                                              Failed to acquire the Mutex because an OS failure occurred.
99          */
100         result Acquire(long timeout);
101
102         /**
103          *      Releases the Mutex.
104          *
105          *      @since 2.0
106          *      @return                 An error code
107          *      @exception      E_SUCCESS       The method was successful.
108          *      @exception      E_SYSTEM        An unknown operating system error occurred. @n
109          *                                                      Failed to acquire the Mutex because an OS failure occurred.
110          */
111         result Release(void);
112
113         /**
114          *      Acquires the Mutex if it is not acquired. @n
115          *      If the Mutex is already acquired by another thread,
116          *      the current thread is blocked until the Mutex is released.
117          *
118          *      @since 2.0
119          *      @return                 An error code
120          *      @exception      E_SUCCESS               The method was successful.
121          *      @exception      E_SYSTEM                An unknown operating system error occurred. @n
122          *                                                              Failed to acquire the Mutex because an OS failure occurred.
123          */
124         result Acquire(void);
125
126         /**
127          *      Acquires the mutex if it is not acquired. @n
128          *      If the mutex is already acquired by another thread, E_OBJECT_LOCKED is returned.
129          *
130          *      @since 2.0
131          *
132          *      @return                 An error code
133          *      @exception      E_SUCCESS               The method is successful.
134          *      @exception      E_OBJECT_LOCKED         The mutex is already locked.    
135          *      @exception      E_INVALID_STATE         The mutex has not been initialized as yet.
136          *      @exception      E_SYSTEM                A system error has occurred.
137          */
138         result TryToAcquire(void);
139
140 private:
141         pthread_mutex_t* __pMutex;
142         String __name;
143
144 };
145
146
147
148 TIZEN_MAPS_END_NAMESPACE
149     
150 #endif // _TIZEN_MAPS_MUTEX_H_
151