readAsBytesLimited method
Similar to File.readAsBytes, but limits concurrency to a
maximum of _semaphoreLimit simultaneous reads.
This helps prevent Too many open files errors and reduces
disk I/O contention or throttling on shared or virtualized
storage systems.
Implementation
Future<Uint8List> readAsBytesLimited() async {
await _semaphore.acquire();
try {
return await readAsBytes();
} finally {
_semaphore.release();
}
}