2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FBaseRtMonitorGuard.h
20 * @brief This is the header file for the %MonitorGuard class.
22 * This header file contains the declarations of the %MonitorGuard class.
25 #ifndef _FBASE_RT_MONITOR_GUARD_H_
26 #define _FBASE_RT_MONITOR_GUARD_H_
28 #include <FBaseRtMonitor.h>
30 namespace Tizen { namespace Base { namespace Runtime
35 * @brief This class is the RAII style class for %Monitor class.
43 * This constructor enters the monitored block in a blocking way.
47 * @param[in] m The %Monitor instance to be manipulated
48 * @remarks The specific error code can be accessed using the GetLastResult() method.
49 * @see Monitor::Enter() for detailed exceptions
51 MonitorGuard(Monitor& m)
55 SetLastResult(SetEnteredAndReturn(__m.Enter()));
59 * This destructor exits the monitored block when going out of a scope
63 * @remarks The specific error code can be accessed using the GetLastResult() method.
64 * @see Monitor::Exit() for detailed exceptions
78 * Returns whether this instance owns the lock on the given monitor at constructor.
82 * @return true if the lock is owned, @n
85 bool IsEntered(void) const
91 * Returns whether this instance owns the lock on the given monitor at constructor. @n
92 * Have same effects to calling IsEntered().
103 * The implementation of this copy constructor is intentionally blank and declared as private
104 * to prohibit copying of objects.
108 MonitorGuard(const MonitorGuard& rhs);
111 * The implementation of this copy assignment operator is intentionally blank and declared as private
112 * to prohibit copying of objects.
116 MonitorGuard& operator =(const MonitorGuard& rhs);
119 result SetEnteredAndReturn(result r)
121 __entered = (r == E_SUCCESS);
130 }}} // Tizen::Base::Runtime
132 #endif // _FBASE_RT_MONITOR_GUARD_H_