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 FBaseRtThreadMonitor.cpp
19 * @brief This is the implementation file for the Monitor class.
25 #include <FBaseRtMonitor.h>
27 #include <FBaseSysLog.h>
28 #include "FBaseRt_MonitorImpl.h"
31 namespace Tizen { namespace Base { namespace Runtime
34 Monitor::Monitor(void)
35 : __pMonitorImpl(null)
40 Monitor::~Monitor(void)
42 delete __pMonitorImpl;
43 __pMonitorImpl = null;
47 Monitor::Construct(void)
49 // Object is not allowed to construct twice
50 SysAssertf(__pMonitorImpl == null,
51 "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class");
54 __pMonitorImpl = new (std::nothrow) _MonitorImpl;
55 SysTryReturnResult(NID_BASE_RT, __pMonitorImpl != null, E_OUT_OF_MEMORY, "Not enough memory.");
57 r = __pMonitorImpl->Construct();
60 delete __pMonitorImpl;
61 __pMonitorImpl = null;
70 SysAssertf(__pMonitorImpl != null, "Not yet constructed! Construct() should be called before use.");
72 result r = __pMonitorImpl->Enter();
73 SysTryReturn(NID_BASE_RT, r == E_SUCCESS, r, r, "[%s] System error has occurred", GetErrorMessage(r));
81 SysAssertf(__pMonitorImpl != null, "Not yet constructed! Construct() should be called before use.");
83 result r = __pMonitorImpl->Exit();
84 SysTryReturn(NID_BASE_RT, r == E_SUCCESS, r, r, "[%s] System error has occurred", GetErrorMessage(r));
92 SysAssertf(__pMonitorImpl != null, "Not yet constructed! Construct() should be called before use.");
94 result r = __pMonitorImpl->Wait();
95 SysTryReturn(NID_BASE_RT, r == E_SUCCESS, r, r, "[%s] System error has occurred", GetErrorMessage(r));
101 Monitor::Notify(void)
103 SysAssertf(__pMonitorImpl != null, "Not yet constructed! Construct() should be called before use.");
105 result r = __pMonitorImpl->Notify();
106 SysTryReturn(NID_BASE_RT, r == E_SUCCESS, r, r, "[%s] System error has occurred", GetErrorMessage(r));
112 Monitor::NotifyAll(void)
114 SysAssertf(__pMonitorImpl != null, "Not yet constructed! Construct() should be called before use.");
116 result r = __pMonitorImpl->NotifyAll();
117 SysTryReturn(NID_BASE_RT, r == E_SUCCESS, r, r, "[%s] System error has occurred", GetErrorMessage(r));
122 } } } // Tizen::Runtime