diff options
Diffstat (limited to 'src/FLoc_LocationManager.cpp')
-rw-r--r-- | src/FLoc_LocationManager.cpp | 47 |
1 files changed, 41 insertions, 6 deletions
diff --git a/src/FLoc_LocationManager.cpp b/src/FLoc_LocationManager.cpp index 394590e..634c950 100644 --- a/src/FLoc_LocationManager.cpp +++ b/src/FLoc_LocationManager.cpp @@ -66,11 +66,13 @@ _LocationManager::_LocationManager(void) , __pLocRequestInfoList(null) , __pSyncLocRequestInfoList(null) , __pLocUpdateTimer(null) + , __pInitMonitor(null) { } _LocationManager::~_LocationManager(void) { + delete __pInitMonitor; } result @@ -684,7 +686,17 @@ _LocationManager::Reset(void) result _LocationManager::Construct() { - return EventDrivenThread::Construct(); + result r = EventDrivenThread::Construct(); + SysTryReturnResult(NID_LOC, r == E_SUCCESS, r, "[%s] Failed to Construct", GetErrorMessage(r)); + + std::unique_ptr< Monitor > pMonitor(new (std::nothrow) Monitor()); + SysTryReturnResult(NID_LOC, pMonitor, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + r = pMonitor->Construct(); + SysTryReturnResult(NID_LOC, r == E_SUCCESS, r, "[%s] Failed to Construct Monitor. Propagating.", GetErrorMessage(r)); + + __pInitMonitor = pMonitor.release(); + + return E_SUCCESS; } Location @@ -977,6 +989,8 @@ _LocationManager::GetLocation(location_method_e nativeLocMethod) bool _LocationManager::OnStart(void) { + SysTryReturn(NID_LOC, __pInitMonitor, false, E_INVALID_STATE, "[E_INVALID_STATE] __pInitMonitor must not be null."); + int res = -1; std::unique_ptr< Tizen::Base::Collection::ArrayList, AllElementsDeleter > pLocInfoRequestList(new (std::nothrow) ArrayList()); @@ -1014,7 +1028,13 @@ _LocationManager::OnStart(void) __gpsHandler.pLocation= std::move(pGpsLocation); __wpsHandler.pLocation= std::move(pWpsLocation); - __waitLoopListener.SetValue(true); + r = __pInitMonitor->Enter(); + SysTryCatch(NID_LOC, r == E_SUCCESS, , r, "[%s] Failed to Enter Monitor. Propagating.", GetErrorMessage(r)); + r = __pInitMonitor->Notify(); + SysTryCatch(NID_LOC, r == E_SUCCESS, , r, "[%s] Failed to Notify Monitor. Propagating.", GetErrorMessage(r)); + r = __pInitMonitor->Exit(); + SysTryCatch(NID_LOC, r == E_SUCCESS, , r, "[%s] Failed to Exit Monitor. Propagating.", GetErrorMessage(r)); + SysLog(NID_LOC, "All the resources for location manager successfully created."); return true; @@ -1034,7 +1054,8 @@ CATCH: void _LocationManager::OnStop(void) { - __waitLoopListener.SetValue(false); + delete __pInitMonitor; + __pInitMonitor = null; if (__gpsHandler.handle) { @@ -1308,11 +1329,13 @@ _LocationManager::InitLocationManager(void) unique_ptr< _LocationManager > pLocMgr(new (std::nothrow) _LocationManager()); SysTryReturnVoidResult(NID_LOC, pLocMgr, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); result r = pLocMgr->Construct(); - SysTryReturnVoidResult(NID_LOC, r == E_SUCCESS, r, "[%s] Falied to construct the Location Manager. Propagating.", GetErrorMessage(r)); + SysTryReturnVoidResult(NID_LOC, r == E_SUCCESS, r, "[%s] Failed to construct the Location Manager. Propagating.", GetErrorMessage(r)); + r = pLocMgr->Start(); - SysTryReturnVoidResult(NID_LOC, r == E_SUCCESS, r, "[%s] Falied to start the Location Manager. Propagating.", GetErrorMessage(r)); + SysTryReturnVoidResult(NID_LOC, r == E_SUCCESS, r, "[%s] Failed to start the Location Manager. Propagating.", GetErrorMessage(r)); - WaitingLoop::GetInstance()->Wait(*pLocMgr->GetWaitLoopListener()); + r = pLocMgr->WaitThreadStart(); + SysTryReturnVoidResult(NID_LOC, r == E_SUCCESS, r, "[%s] Failed to WaitThreadStart. Propagating.", GetErrorMessage(r)); __pUniqueInstance = pLocMgr.release(); std::atexit(DestroyLocationManager); @@ -1324,4 +1347,16 @@ _LocationManager::DestroyLocationManager(void) delete __pUniqueInstance; } +result +_LocationManager::WaitThreadStart() +{ + result r = __pInitMonitor->Enter(); + SysTryReturnResult(NID_LOC, r == E_SUCCESS, r, "[%s] Failed to Enter Monitor. Propagating.", GetErrorMessage(r)); + r = __pInitMonitor->Wait(); + SysTryReturnResult(NID_LOC, r == E_SUCCESS, r, "[%s] Failed to Wait Monitor. Propagating.", GetErrorMessage(r)); + r = __pInitMonitor->Exit(); + SysTryReturnResult(NID_LOC, r == E_SUCCESS, r, "[%s] Failed to Exit Monitor. Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} }} |