2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FBaseRtMonitorGuard.h
19 * @brief This is the header file for the %MonitorGuard class.
21 * This header file contains the declarations of the %MonitorGuard class.
24 #ifndef _FBASE_RT_MONITOR_GUARD_H_
25 #define _FBASE_RT_MONITOR_GUARD_H_
27 #include <FBaseRtMonitor.h>
29 namespace Tizen { namespace Base { namespace Runtime
34 * @brief This class is the RAII style class for %Monitor class.
42 * This constructor enters the monitored block in a blocking way.
46 * @param[in] m The %Monitor instance to be manipulated
47 * @remarks The specific error code can be accessed using the GetLastResult() method.
48 * @see Monitor::Enter() for detailed exceptions
50 MonitorGuard(Monitor& m)
54 SetLastResult(SetEnteredAndReturn(__m.Enter()));
58 * This destructor exits the monitored block when going out of a scope
62 * @remarks The specific error code can be accessed using the GetLastResult() method.
63 * @see Monitor::Exit() for detailed exceptions
77 * Returns whether this instance owns the lock on the given monitor at constructor.
81 * @return true if the lock is owned, @n
84 bool IsEntered(void) const
90 * Returns whether this instance owns the lock on the given monitor at constructor. @n
91 * Have same effects to calling IsEntered().
102 * The implementation of this copy constructor is intentionally blank and declared as private
103 * to prohibit copying of objects.
107 MonitorGuard(const MonitorGuard& rhs);
110 * The implementation of this copy assignment operator is intentionally blank and declared as private
111 * to prohibit copying of objects.
115 MonitorGuard& operator =(const MonitorGuard& rhs);
118 result SetEnteredAndReturn(result r)
120 __entered = (r == E_SUCCESS);
129 }}} // Tizen::Base::Runtime
131 #endif // _FBASE_RT_MONITOR_GUARD_H_