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 FBaseRt_MonitorImpl.h
19 * @brief This is the header file for the %_Monitor class.
21 * This file contains the declarations of the %_Monitor class.
24 #ifndef _FBASE_RT_INTERNAL_MONITOR_IMPL_H_
25 #define _FBASE_RT_INTERNAL_MONITOR_IMPL_H_
29 #include <FBaseResult.h>
30 #include <FBaseObject.h>
33 namespace Tizen { namespace Base { namespace Runtime
38 * @brief This is one of the synchronization mechanisms. It not only provides acquire/release semantics
39 * (by Enter/Exit), but also wait/notify semantics (by Wait/Notify/NotifyAll).
45 : public Tizen::Base::Object
49 * This is the default constructor for this class.
52 * @remarks After creating an instance of this class, you must explicitly call one of the
53 * Construct() methods to initialize the instance.
59 * This is the destructor for this class.
67 * Creates the monitor instance.
70 * @return An error code
71 * @exception E_SUCCESS The method was successful.
72 * @exception E_SYSTEM An unknown operating system error occurred.
74 result Construct(void);
78 * Acquires a lock for a monitor. @n
79 * Semantically, this method declares the beginning of the critical region for a monitor. This region is
80 * ended with the Exit() method.
83 * @return An error code
84 * @exception E_SUCCESS The method was successful. @n
85 * It was successful in acquiring the lock.
92 * Releases a lock for a monitor. @n
93 * Semantically, it declares the ending of the critical region for the monitor which begins by
97 * @return An error code
98 * @exception E_SUCCESS The method was successful. @n
99 * It was successful in releasing the lock.
100 * @exception E_INVALID_STATE The current thread has not entered the monitor.
106 * Releases the lock for the monitor and waits for the other thread's notification. @n
107 * After receiving the notification, it tries to acquire the lock. @n
108 * Semantically, it waits until the other thread notifies it.
111 * @return An error code
112 * @exception E_SUCCESS The method was successful.
113 * @see Notify(), NotifyAll()
118 * Notifies one of the waiting threads. @n
119 * The selection of the notified thread is dependent on the underlying OS.
122 * @return An error code
123 * @exception E_SUCCESS The method was successful.
124 * @see NotifyAll(), Wait()
130 * Notifies all waiting threads.
133 * @return An error code
134 * @exception E_SUCCESS The method was successful.
135 * @see Notify(), Wait()
137 result NotifyAll(void);
141 pthread_mutex_t __lock;
142 pthread_cond_t __cond;
146 } } } // Tizen::Base::Runtime
148 #endif // _FBASE_RT_INTERNAL_MONITOR_IMPL_H_