sync#

Flush pending writes from a mapped scalar back to disk.

Synopsis#

sync $map;         # synchronous — wait for the kernel to finish
sync $map, 0;      # asynchronous — queue the flush and return

Arguments#

  • $lvalue — a currently mapped scalar.

  • $synchronous — defaults to true. When true, sync does not return until the kernel reports the data on stable storage. When false, the flush is only queued.

The mapping is always flushed automatically when the scalar goes out of scope, so explicit calls to sync are only needed when you want other processes, or a crash-safe on-disk snapshot, to see the changes before then.

Edge cases#

  • Calling sync on an unmapped scalar raises an exception.

  • Calling sync on an empty mapping is a no-op.

Differences from upstream#

Fully compatible with upstream File::Map 0.71.

See also#

  • unmap — release the mapping (also triggers a flush).

  • advise — influence the kernel’s write-back strategy.