import 'package:meta/meta.dart'; /// Runs an action once for everyone who asks: a caller while it runs awaits /// the same run, and one after it is done gets it done; only a run that /// failed is run again by the next caller. @internal class Once { Future? _run; /// Runs [action] unless it ran or runs already, and completes with that /// run. Future run(Future Function() action) async { final run = _run ??= action(); try { await run; } catch (_) { if (identical(_run, run)) _run = null; rethrow; } } }