tom_core_kernel_io library

The dart:io-only part of tom_core_kernel.

package:tom_core_kernel/tom_core_kernel.dart is platform-neutral and compiles for the web. What needs a filesystem lives here instead, so that importing it is a decision a caller makes knowingly: only code that runs natively — desktop, mobile, server — may import this library, and a package that also targets the web reaches it through a conditional import.

Today that is the cross-isolate, cross-process file guard the kernel's file-backed stores use: tomWithFileLock waits synchronously, tomWithFileLockAsync without blocking its isolate, and both exclude every other holder of the same guard file — other tasks, isolates and processes alike. See doc/little_things.md, "Guarding a file against a second writer".

Constants

tomFileLockStaleAfter → const Duration
How long a guard may stand unchanged before it is presumed abandoned.

Functions

tomFileLockPath(String path) → String
The guard file protecting path.
tomWithFileLock<T>(File lockFile, T body(), {Duration staleAfter = tomFileLockStaleAfter, Duration timeout = const Duration(seconds: 30), void onBrokenLock(String warning)?}) → T
Runs body with exclusive access to lockFile among every isolate and process using this guard, and releases it however body ends.
tomWithFileLockAsync<T>(File lockFile, Future<T> body(), {Duration staleAfter = tomFileLockStaleAfter, Duration timeout = const Duration(seconds: 30), void onBrokenLock(String warning)?}) → Future<T>
tomWithFileLock for a caller that must not block its isolate while it waits: the waits between attempts are Future.delayed, and body may be asynchronous.