From 0df749e3635c8568c38babdfad81a4b0d1e5ce39 Mon Sep 17 00:00:00 2001 From: Nilesh Gharde Date: Thu, 29 Aug 2019 14:24:46 +0530 Subject: Adding one level of context swith for Geofence_add Added one more context switch for geofence add command. To even out total number of the context switch as it is for remove/modify/pause command. This will prevent out of order execution of sent msg tasks. Change-Id: Icf1f39ee3526e2e45cfe3e84945f71524941069b CRs-Fixed: 2516790 --- geofence/GeofenceAdapter.cpp | 49 +++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 23 deletions(-) (limited to 'geofence/GeofenceAdapter.cpp') diff --git a/geofence/GeofenceAdapter.cpp b/geofence/GeofenceAdapter.cpp index b8746fb..e299589 100644 --- a/geofence/GeofenceAdapter.cpp +++ b/geofence/GeofenceAdapter.cpp @@ -242,30 +242,33 @@ GeofenceAdapter::addGeofencesCommand(LocationAPI* client, size_t count, Geofence if (NULL == mIds || NULL == mOptions || NULL == mInfos) { errs[i] = LOCATION_ERROR_INVALID_PARAMETER; } else { - mApi.addGeofence(mIds[i], - mOptions[i], - mInfos[i], - new LocApiResponseData(*mAdapter.getContext(), - [&mAdapter = mAdapter, mOptions = mOptions, mClient = mClient, - mCount = mCount, mIds = mIds, mInfos = mInfos, errs, i] - (LocationError err, LocApiGeofenceData data) { - if (LOCATION_ERROR_SUCCESS == err) { - mAdapter.saveGeofenceItem(mClient, - mIds[i], - data.hwId, - mOptions[i], - mInfos[i]); - } - errs[i] = err; + mApi.addToCallQueue(new LocApiResponse(*mAdapter.getContext(), + [&mAdapter = mAdapter, mCount = mCount, mClient = mClient, + mOptions = mOptions, mInfos = mInfos, mIds = mIds, &mApi = mApi, + errs, i] (LocationError err ) { + mApi.addGeofence(mIds[i], mOptions[i], mInfos[i], + new LocApiResponseData(*mAdapter.getContext(), + [&mAdapter = mAdapter, mOptions = mOptions, mClient = mClient, + mCount = mCount, mIds = mIds, mInfos = mInfos, errs, i] + (LocationError err, LocApiGeofenceData data) { + if (LOCATION_ERROR_SUCCESS == err) { + mAdapter.saveGeofenceItem(mClient, + mIds[i], + data.hwId, + mOptions[i], + mInfos[i]); + } + errs[i] = err; - // Send aggregated response on last item and cleanup - if (i == mCount-1) { - mAdapter.reportResponse(mClient, mCount, errs, mIds); - delete[] errs; - delete[] mIds; - delete[] mOptions; - delete[] mInfos; - } + // Send aggregated response on last item and cleanup + if (i == mCount-1) { + mAdapter.reportResponse(mClient, mCount, errs, mIds); + delete[] errs; + delete[] mIds; + delete[] mOptions; + delete[] mInfos; + } + })); })); } } -- cgit v1.2.3