MCPcopy Create free account
hub / github.com/apache/arrow / RunInScheduler

Method RunInScheduler

cpp/src/arrow/filesystem/s3fs.cc:2894–2911  ·  view source on GitHub ↗

Some operations require running multiple S3 calls, either in parallel or serially. We need to ensure that the S3 filesystem instance stays valid and that S3 isn't finalized. We do this by wrapping all the tasks in a scheduler which keeps the resources alive

Source from the content-addressed store, hash-verified

2892 // finalized. We do this by wrapping all the tasks in a scheduler which keeps the
2893 // resources alive
2894 Future<> RunInScheduler(
2895 std::function<Status(util::AsyncTaskScheduler*, S3FileSystem::Impl*)> callable) {
2896 auto self = shared_from_this();
2897 FnOnce<Status(util::AsyncTaskScheduler*)> initial_task =
2898 [callable = std::move(callable),
2899 this](util::AsyncTaskScheduler* scheduler) mutable {
2900 return callable(scheduler, this);
2901 };
2902 Future<> scheduler_fut = util::AsyncTaskScheduler::Make(
2903 std::move(initial_task),
2904 /*abort_callback=*/
2905 [](const Status& st) {
2906 // No need for special abort logic.
2907 },
2908 io_context_.stop_token());
2909 // Keep self alive until all tasks finish
2910 return scheduler_fut.Then([self]() { return Status::OK(); });
2911 }
2912
2913 Future<> DoDeleteDirContentsAsync(const std::string& bucket, const std::string& key) {
2914 return RunInScheduler(

Callers

nothing calls this directly

Calls 3

ThenMethod · 0.80
MakeFunction · 0.50
OKFunction · 0.50

Tested by

no test coverage detected