FileLimitExtension extension

Provides global concurrency control for file I/O operations.

This extension uses a shared Semaphore to limit the number of simultaneous file reads or writes. It helps prevent Too many open files errors and mitigates disk I/O contention or throttling on shared or virtualized storage systems (e.g., cloud VMs or containers).

on

Methods

deleteLimited({bool recursive = false}) Future<void>

Available on File, provided by the FileLimitExtension extension

Similar to File.delete, but limits concurrency to the current semaphore limit to avoid excessive parallel I/O operations.
exists() Future<void>

Available on File, provided by the FileLimitExtension extension

Similar to File.exists, but respects the current semaphore limit to prevent excessive parallel filesystem checks.
readAsBytesLimited() Future<Uint8List>

Available on File, provided by the FileLimitExtension extension

Similar to File.readAsBytes, but limits concurrency to a maximum of _semaphoreLimit simultaneous reads.
statLimited() Future<FileStat>

Available on File, provided by the FileLimitExtension extension

Similar to File.stat, but limits concurrency to the current semaphore limit to reduce excessive parallel I/O operations.
writeAsBytesLimited(List<int> bytes, {FileMode mode = FileMode.write, bool flush = false}) Future<File>

Available on File, provided by the FileLimitExtension extension

Similar to File.writeAsBytes, but limits concurrency to a maximum of _semaphoreLimit simultaneous writes.

Static Methods

getSemaphoreLimit() int

Available on File, provided by the FileLimitExtension extension

Returns the current maximum number of concurrent file operations.
setSemaphoreLimit(int limit) → void

Available on File, provided by the FileLimitExtension extension

Updates the maximum number of concurrent file operations.