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

Method EnsureInitialized

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

Returns true iff the instance was newly initialized with `options`

Source from the content-addressed store, hash-verified

3482
3483 // Returns true iff the instance was newly initialized with `options`
3484 Result<bool> EnsureInitialized(const S3GlobalOptions& options) {
3485 // NOTE: The individual accesses are atomic but the entire sequence below is not.
3486 // The application should serialize calls to InitializeS3() and FinalizeS3()
3487 // (see docstrings).
3488 if (is_finalized_.load()) {
3489 return Status::Invalid("Attempt to initialize S3 after it has been finalized");
3490 }
3491 bool newly_initialized = false;
3492 // EnsureInitialized() can be called concurrently by FileSystemFromUri,
3493 // therefore we need to serialize initialization (GH-39897).
3494 std::call_once(initialize_flag_, [&]() {
3495 bool was_initialized = is_initialized_.exchange(true);
3496 DCHECK(!was_initialized);
3497 DoInitialize(options);
3498 newly_initialized = true;
3499 });
3500 return newly_initialized;
3501 }
3502
3503 bool IsInitialized() { return !is_finalized_ && is_initialized_; }
3504

Callers 1

Calls 2

InvalidFunction · 0.50
loadMethod · 0.45

Tested by

no test coverage detected