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 FBaseRt_MonitorImpl.cpp
20 * @brief This is the implementation file for the _MonitorImpl class.
24 #include <FBaseSysLog.h>
25 #include "FBaseRt_MonitorImpl.h"
27 namespace Tizen { namespace Base { namespace Runtime
30 _MonitorImpl::_MonitorImpl(void)
31 : __initialized(false)
36 _MonitorImpl::~_MonitorImpl(void)
40 pthread_cond_destroy(&__cond);
41 pthread_mutex_destroy(&__lock);
46 _MonitorImpl::Construct(void)
50 ret = pthread_mutex_init(&__lock, null);
51 SysTryReturnResult(NID_BASE_RT, ret == 0, E_SYSTEM, "[E_SYSTEM] System error has occurred.");
53 ret = pthread_cond_init(&__cond, null);
54 SysTryReturnResult(NID_BASE_RT, ret == 0, E_SYSTEM, "[E_SYSTEM] System error has occurred.");
62 _MonitorImpl::Enter(void)
66 ret = pthread_mutex_lock(&__lock);
67 SysTryReturnResult(NID_BASE_RT, ret == 0, E_SYSTEM, "[E_SYSTEM] System error has occurred.");
73 _MonitorImpl::Exit(void)
77 ret = pthread_mutex_unlock(&__lock);
78 SysTryReturnResult(NID_BASE_RT, ret == 0, E_SYSTEM, "[E_SYSTEM] System error has occurred.");
84 _MonitorImpl::Wait(void)
88 ret = pthread_cond_wait(&__cond, &__lock);
89 SysTryReturnResult(NID_BASE_RT, ret == 0, E_SYSTEM, "[E_SYSTEM] System error has occurred.");
95 _MonitorImpl::Notify(void)
99 ret = pthread_cond_signal(&__cond);
100 SysTryReturnResult(NID_BASE_RT, ret == 0, E_SYSTEM, "[E_SYSTEM] System error has occured.");
106 _MonitorImpl::NotifyAll(void)
110 ret = pthread_cond_broadcast(&__cond);
111 SysTryReturnResult(NID_BASE_RT, ret == 0, E_SYSTEM, "[E_SYSTEM] System error has occurred.");
116 } } } // Tizen::Runtime