@@ -177,22 +177,19 @@ client::CancellationToken VersionedLayerClientImpl::PrefetchPartitions(
177177
178178 client::CancellationContext execution_context;
179179
180- auto prefetch_callback = [=](PrefetchPartitionsResponse response) {
181- if (execution_context.IsCancelled ()) {
182- callback (ApiError (ErrorCode::Cancelled, " Canceled" ));
183- } else {
184- callback (response);
185- }
186- };
187-
188180 return task_sink_.AddTask (
189181 [=](client::CancellationContext context) {
182+ if (context.IsCancelled ()) {
183+ callback (ApiError (ErrorCode::Cancelled, " Canceled" ));
184+ return ;
185+ }
186+
190187 if (request.GetPartitionIds ().empty ()) {
191188 OLP_SDK_LOG_WARNING_F (
192189 kLogTag ,
193190 " PrefetchPartitions : invalid request, catalog=%s, layer=%s" ,
194191 catalog_.ToCatalogHRNString ().c_str (), layer_id_.c_str ());
195- prefetch_callback (
192+ callback (
196193 ApiError (ErrorCode::InvalidArgument, " Empty partitions list" ));
197194 return ;
198195 }
@@ -209,7 +206,7 @@ client::CancellationToken VersionedLayerClientImpl::PrefetchPartitions(
209206 " failed, catalog=%s, key=%s" ,
210207 catalog_.ToCatalogHRNString ().c_str (),
211208 key.c_str ());
212- prefetch_callback (response.GetError ());
209+ callback (response.GetError ());
213210 return ;
214211 }
215212
@@ -282,13 +279,13 @@ client::CancellationToken VersionedLayerClientImpl::PrefetchPartitions(
282279 };
283280
284281 auto call_user_callback =
285- [prefetch_callback ](PrefetchPartitionsResponse result) {
282+ [callback ](PrefetchPartitionsResponse result) {
286283 if (result.IsSuccessful () &&
287284 result.GetResult ().GetPartitions ().size () == 0 ) {
288- prefetch_callback (ApiError (client::ErrorCode::Unknown,
289- " No partitions were prefetched." ));
285+ callback (ApiError (client::ErrorCode::Unknown,
286+ " No partitions were prefetched." ));
290287 } else {
291- prefetch_callback (std::move (result));
288+ callback (std::move (result));
292289 }
293290 };
294291
@@ -327,22 +324,18 @@ client::CancellationToken VersionedLayerClientImpl::PrefetchTiles(
327324
328325 client::CancellationContext execution_context;
329326
330- auto prefetch_callback = [=](PrefetchTilesResponse response) {
331- if (execution_context.IsCancelled ()) {
332- callback (ApiError (ErrorCode::Cancelled, " Canceled" ));
333- } else {
334- callback (response);
335- }
336- };
337-
338327 return task_sink_.AddTask (
339328 [=](client::CancellationContext context) mutable -> void {
329+ if (context.IsCancelled ()) {
330+ callback (ApiError (ErrorCode::Cancelled, " Canceled" ));
331+ return ;
332+ }
333+
340334 if (request.GetTileKeys ().empty ()) {
341335 OLP_SDK_LOG_WARNING_F (
342336 kLogTag , " PrefetchTiles : invalid request, catalog=%s, layer=%s" ,
343337 catalog_.ToCatalogHRNString ().c_str (), layer_id_.c_str ());
344- prefetch_callback (
345- ApiError (ErrorCode::InvalidArgument, " Empty tile key list" ));
338+ callback (ApiError (ErrorCode::InvalidArgument, " Empty tile key list" ));
346339 return ;
347340 }
348341
@@ -355,7 +348,7 @@ client::CancellationToken VersionedLayerClientImpl::PrefetchTiles(
355348 OLP_SDK_LOG_WARNING_F (
356349 kLogTag , " PrefetchTiles: getting catalog version failed, key=%s" ,
357350 key.c_str ());
358- prefetch_callback (response.GetError ());
351+ callback (response.GetError ());
359352 return ;
360353 }
361354
@@ -390,7 +383,7 @@ client::CancellationToken VersionedLayerClientImpl::PrefetchTiles(
390383 OLP_SDK_LOG_WARNING_F (kLogTag ,
391384 " PrefetchTiles: tile/level mismatch, key=%s" ,
392385 key.c_str ());
393- prefetch_callback (
386+ callback (
394387 ApiError (ErrorCode::InvalidArgument, " TileKeys/levels mismatch" ));
395388 return ;
396389 }
@@ -461,8 +454,8 @@ client::CancellationToken VersionedLayerClientImpl::PrefetchTiles(
461454 };
462455
463456 auto download_job = std::make_shared<PrefetchTilesHelper::DownloadJob>(
464- std::move (download), std::move (append_result),
465- std::move (prefetch_callback), std::move ( status_callback));
457+ std::move (download), std::move (append_result), std::move (callback),
458+ std::move (status_callback));
466459
467460 return PrefetchTilesHelper::Prefetch (
468461 std::move (download_job), std::move (roots), std::move (query),
0 commit comments