Skip to content

Commit

Permalink
Merge 548c2be into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Apr 17, 2021
2 parents 0f9851c + 548c2be commit 1499fcc
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# 0.1.0+0-alpha
# 0.1.0+1-alpha

- Initial release
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

# schedulers

Objects in this library run callbacks asynchronously, allowing useful pauses
between calls. This can be used for load balancing, rate limiting, lazy execution.
Dart library for running asynchronous functions on time. Useful for
load balancing, rate limiting, lazy execution.

In the examples below, objects receive tasks immediately after
constructors. But in fact, objects can handle calls to the `run` method
at random times. The tasks will be distributed in time in the same way.
*In the examples below, all the `run(callback)` calls are performed right
after object creation. But it fact all the schedulers are ready to handle
`run` calls at random moments.*

# IntervalScheduler

Expand Down
2 changes: 2 additions & 0 deletions lib/src/50_interval.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class IntervalScheduler implements PriorityScheduler {

Future<void> get completed => this._completer.future;

/// Notifies the scheduler that it should run the callback sometime. The actual call will occur
/// asynchronously at the time selected by the scheduler.
@override
Task<T> run<T>(GetterFunc<T> callback, [int priority = 0]) {
if (this._tasks.length <= 0) {
Expand Down
2 changes: 2 additions & 0 deletions lib/src/50_lazy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class LazyScheduler {

Unlimited _newestRunId = Unlimited();

/// Notifies the scheduler that it should run the callback sometime. The actual call will occur
/// asynchronously at the time selected by the scheduler.
void run(GetterFunc<void> callback) async {
this._callback = callback;

Expand Down
2 changes: 2 additions & 0 deletions lib/src/50_rateLimiting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class RateScheduler implements PriorityScheduler {

final Queue<Stopwatch> _recentTimes = Queue<Stopwatch>();

/// Notifies the scheduler that it should run the callback sometime. The actual call will occur
/// asynchronously at the time selected by the scheduler.
@override
Task<T> run<T>(GetterFunc<T> callback, [int priority = 0]) {
Task<T>? result;
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: schedulers
description: Running callbacks asynchronously, with useful pauses between calls.
description: Dart library for running asynchronous functions on time. Useful for load balancing, rate limiting, lazy execution.
repository: https://github.com/rtmigo/schedulers

version: 0.1.0+0-alpha
version: 0.1.0+1-alpha

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down

0 comments on commit 1499fcc

Please sign in to comment.