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.cpp
19 * @brief This is the implementation file for the _MonitorImpl class.
23 #include <FBaseSysLog.h>
24 #include "FBaseRt_MonitorImpl.h"
26 namespace Tizen { namespace Base { namespace Runtime
29 _MonitorImpl::_MonitorImpl(void)
30 : __initialized(false)
35 _MonitorImpl::~_MonitorImpl(void)
39 pthread_cond_destroy(&__cond);
40 pthread_mutex_destroy(&__lock);
45 _MonitorImpl::Construct(void)
49 ret = pthread_mutex_init(&__lock, null);
50 SysTryReturnResult(NID_BASE_RT, ret == 0, E_SYSTEM, "[E_SYSTEM] System error has occurred.");
52 ret = pthread_cond_init(&__cond, null);
53 SysTryReturnResult(NID_BASE_RT, ret == 0, E_SYSTEM, "[E_SYSTEM] System error has occurred.");
61 _MonitorImpl::Enter(void)
65 ret = pthread_mutex_lock(&__lock);
66 SysTryReturnResult(NID_BASE_RT, ret == 0, E_SYSTEM, "[E_SYSTEM] System error has occurred.");
72 _MonitorImpl::Exit(void)
76 ret = pthread_mutex_unlock(&__lock);
77 SysTryReturnResult(NID_BASE_RT, ret == 0, E_SYSTEM, "[E_SYSTEM] System error has occurred.");
83 _MonitorImpl::Wait(void)
87 ret = pthread_cond_wait(&__cond, &__lock);
88 SysTryReturnResult(NID_BASE_RT, ret == 0, E_SYSTEM, "[E_SYSTEM] System error has occurred.");
94 _MonitorImpl::Notify(void)
98 ret = pthread_cond_signal(&__cond);
99 SysTryReturnResult(NID_BASE_RT, ret == 0, E_SYSTEM, "[E_SYSTEM] System error has occured.");
105 _MonitorImpl::NotifyAll(void)
109 ret = pthread_cond_broadcast(&__cond);
110 SysTryReturnResult(NID_BASE_RT, ret == 0, E_SYSTEM, "[E_SYSTEM] System error has occurred.");
115 } } } // Tizen::Runtime