summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchanil.byun <chanil.byun@samsung.com>2013-04-25 18:11:41 +0900
committerchanil.byun <chanil.byun@samsung.com>2013-04-25 21:30:20 +0900
commit77129ab953efd6c87cbffc3544256a126656e94c (patch)
treec686ff7deebb5d0889818b968150eebd05e12707
parent5fecf3d30a386c4bb5023e900ed741d9b6bb4059 (diff)
downloadlocations-tizen_2.1.tar.gz
locations-tizen_2.1.tar.bz2
locations-tizen_2.1.zip
Change-Id: I81ead12bd6e99ba624d45f0f51f0dc5054ea6a59 Signed-off-by: chanil.byun <chanil.byun@samsung.com>
-rw-r--r--src/FLoc_LocationManager.cpp47
-rw-r--r--src/FLoc_LocationManager.h8
2 files changed, 49 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;
+}
}}
diff --git a/src/FLoc_LocationManager.h b/src/FLoc_LocationManager.h
index af29cea..5723199 100644
--- a/src/FLoc_LocationManager.h
+++ b/src/FLoc_LocationManager.h
@@ -179,10 +179,17 @@ private:
//
void Reset(void);
+ // The method is wait for OnStart method.
+ //
+ // @since 2.0
+ //
+ result WaitThreadStart();
+
// The method calls the construct method of the event driven thread.
//
// @since 2.0
//
+
result Construct(void);
// This method is gets the last known location from Native side for the given method.
@@ -326,6 +333,7 @@ private:
std::unique_ptr< Tizen::Base::Runtime::Timer > __pLocUpdateTimer;
static _LocationManager* __pUniqueInstance;
_WaitLoopListener __waitLoopListener;
+ Tizen::Base::Runtime::Monitor* __pInitMonitor;
friend class std::default_delete< _LocationManager >;
}; // class _LocationManager