Skip to content

Commit

Permalink
Updated documentation comments (#226)
Browse files Browse the repository at this point in the history
* Updated documentation comments

* Update neat_periodic_task/lib/neat_periodic_task.dart

Co-authored-by: Sigurd Meldgaard <[email protected]>

---------

Co-authored-by: Sigurd Meldgaard <[email protected]>
  • Loading branch information
jonasfj and sigurdm authored Jan 11, 2024
1 parent 417b9f4 commit 06c46d3
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions neat_periodic_task/lib/neat_periodic_task.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class NeatPeriodicTaskScheduler {
final Duration _minCycle;
final Duration _maxCycle;

bool _running = false;
bool _started = false;
final _stopping = Completer<void>();
final _stopped = Completer<void>();

Expand Down Expand Up @@ -171,11 +171,15 @@ class NeatPeriodicTaskScheduler {
}

/// Start the scheduler.
///
/// Once started a [NeatPeriodicTaskScheduler] cannot be restarted.
void start() {
if (_running) {
throw StateError('NeatPeriodicTaskScheduler for "$_name" is running');
if (_started) {
throw StateError(
'NeatPeriodicTaskScheduler for "$_name" has already been started',
);
}
_running = true;
_started = true;

_log.fine(() => 'NeatPeriodicTaskScheduler "$_name" STARTING');
scheduleMicrotask(_loop);
Expand All @@ -186,6 +190,8 @@ class NeatPeriodicTaskScheduler {
/// This returns a [Future] that is completed when the scheduler has finished
/// any on-going iterations. This will not abort an ongoing task, but it will
/// stop further iterations of the task.
///
/// Once stopped a [NeatPeriodicTaskScheduler] cannot be started again.
Future<void> stop() async {
if (!_stopping.isCompleted) {
_stopping.complete();
Expand Down

0 comments on commit 06c46d3

Please sign in to comment.