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

Method EnsureInitialized

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

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

Source from the content-addressed store, hash-verified

3413
3414 // Returns true iff the instance was newly initialized with `options`
3415 Result<bool> EnsureInitialized(const S3GlobalOptions& options) {
3416 // NOTE: The individual accesses are atomic but the entire sequence below is not.
3417 // The application should serialize calls to InitializeS3() and FinalizeS3()
3418 // (see docstrings).
3419 if (is_finalized_.load()) {
3420 return Status::Invalid("Attempt to initialize S3 after it has been finalized");
3421 }
3422 bool newly_initialized = false;
3423 // EnsureInitialized() can be called concurrently by FileSystemFromUri,
3424 // therefore we need to serialize initialization (GH-39897).
3425 std::call_once(initialize_flag_, [&]() {
3426 bool was_initialized = is_initialized_.exchange(true);
3427 DCHECK(!was_initialized);
3428 DoInitialize(options);
3429 newly_initialized = true;
3430 });
3431 return newly_initialized;
3432 }
3433
3434 bool IsInitialized() { return !is_finalized_ && is_initialized_; }
3435

Callers 1

Calls 2

InvalidFunction · 0.50
loadMethod · 0.45

Tested by

no test coverage detected