#include "tensorstore/transaction.h"
void tensorstore::Transaction::Barrier() const;

Creates a write barrier. Guarantees that subsequent writes are not committed before any prior write.

This can be used to ensure that metadata updates are committed before data updates that are dependent on the metadata. In particular, this is used to implement certain resize operations and the OpenMode::delete_existing open mode when using isolated transactions.

If atomic(), this has no effect since all writes are committed atomically.

For example:

auto transaction = tensorstore::Transaction(tensorstore::isolated);
tensorstore::Write(data_array | transaction | ..., ...).value();
tensorstore::Write(data_array | transaction | ..., ...).value();
// Ensure writes to `data_array` complete successfully before the
// write to `done_indicator_array` below.
transaction.Barrier();
tensorstore::Write(done_indicator_array | transaction, ...).value();
transaction.Commit().value();