multitasking 7.3.0 copy "multitasking: ^7.3.0" to clipboard
multitasking: ^7.3.0 copied to clipboard

Cooperative multitasking using asynchronous tasks and synchronization primitives, with the ability to safely cancel groups of nested tasks performing I/O wait or listen operations.

Changelog #

7.3.0 #

  • Changed the way cancellation is performed using the zone specification in the ZonedWork class. Now only registered callbacks that can return null are cancelled.

7.2.0 #

  • Added information to the documentation regarding limitations when using ZonedWork due to inherent limitations of the Dart SDK.
  • Added file tool/test_on_web_platform.dart to simplify testing in the browser.
  • An experimental, more aggressive ZonedWork termination mechanism has been implemented.

7.1.0 #

  • Static methods withArgument() were added to the IsolatedWork and ZonedWork classes.
  • Static methods createWithArgument() has been added to the Work class.

7.0.0 #

  • Breaking change: Class IsolateRunner has been renamed to IsolatedWork and moved to directory work.
  • Implemented an experimental feature called Work. A Work is an operation for executing a computation inside the container with the possibility of externally controlled termination.
  • Implemented an experimental feature ZonedWork, for running a computation in a separate Zone, with the possibility of externally controlled termination when control is yielded back to the event loop or using cancellation token.
  • Added class Work.
  • Added class IsolatedWork.
  • Added class ZonedWork.

6.6.0 #

  • Rollback: Removed export of class IsolateRunner from file multitasking.dart.
  • The IsolateRunner class has been moved to the misc/isolate_runner.dart file.

6.5.0 #

  • Implemented an experimental feature for running a computation in a separate Isolate, with the possibility of externally controlled cancellation with immediate termination, with termination when control is yielded back to the event loop, or with termination using cancellation token.
  • Added class IsolateRunner.

6.4.0 #

  • Implemented an experimental feature for canceling a task on request using an internal token.
  • Added combineTokens and token parameters to the default and run constructors of the Task class.
  • Added static getter token to the Task class.

6.3.0 #

  • Changed the implementation of CancelableStreamFactory due to strange behavior of _AsyncStarStreamController.

6.2.0 #

  • Fixed a bug in the implementation of the mechanism for working with timeout in the CancellationTransformer class. Added check for the timeout parameter for a valid value. When the pause event occurs, the timeout timer is cancelled, when the resume event occurs, the timeout timer is restarted, which guarantees full compatibility and correct operation with the await for statement.
  • Added class PauseTransformer.
  • Added example example_stream_timeout_compatibility with_await_for.dart.

6.1.0 #

  • Added class CancelableStreamFactory.
  • Added parameter timeout to the default constructor of the CancellationTransformer class.
  • Added parameter timeout to the asCancelable() method of the StreamExtension extension.
  • Added example example_stream_from_generator_with_cancellation_token.dart.
  • Added example example_stream_cancel_on_timeout.dart.

6.0.0 #

  • Breaking change: Removed withSubscriptionTracking() method from StreamExtension extension.
  • Breaking change: The use of class ErrorResult from package async has been replaced with the use of class AsyncError from package dart:async.
  • Breaking change: The TaskCanceledException class has been renamed to CancellationException.
  • Breaking change: Code normalization, the successful value of the TaskStatus enum has been renamed to succeeded.
  • Breaking change: Code normalization, the incomplete value of the TaskStatus enum has been renamed to pending.
  • Breaking change: The isSuccessful getter of the Task class has been renamed to isSucceeded.
  • Breaking change: The isIncomplete getter of the Task class has been renamed to isPending.
  • Breaking change: The throwIfCanceled parameter of the asCancelable() method of the StreamExtension extension has been removed.
  • Breaking change: The stream subscription cancellation mechanism has been changed. The breaking change is that canceling outgoing subscriptions without the cancelOnError parameter set no longer works (it did not work properly before either due to the fact that in the Dart SDK, stream subscriptions are cancelled upstream but not downstream).
  • Fixed a bug in the asCancelable() method of the StreamExtension extensions. Implementation defects have been corrected.
  • Added classes CancellationException and CancellationTransformer.
  • Added method asPausable() to the StreamExtension extension.
  • Added parameter blockOnCancel to the asCancelable() method of the StreamExtension extension.
  • Added example example_stream_pause_subscription.dart.
  • Added example example_task_pause.dart.
  • Added example example_stream_non_blocking_cancellation.dart.

5.6.0 #

  • Breaking change: Removed listenWithCancellation() method from StreamExtension extension. The reason for removing this method is the need to use a hacked stream subscription. This is now a much cleaner implementation. The closest recommended replacement is the expression stream.asCancelable().listen().
  • The implementation of the asCancelable() method of the StreamExtension extension has been changed.
  • The implementation of the withSubscriptionTracking() method of the StreamExtension extension has been changed. Now it uses an internal, more functional, traceable stream subscription.

5.5.0 #

  • Non-breaking change: Parameter throwIfCanceled of the listenWithCancellation() and asCancelable() methods of the StreamExtension extension is now optional and has a default value of true.
  • The implementation of the listenWithCancellation() method of the StreamExtension class has been changed. Now the operating algorithm is a little simpler and more predictable.

5.4.0 #

  • The implementation of the withCancellationHandler() method from the StreamExtension extension has been changed. The implementation is now more optimized and ensures that the stream subscription has no references to the stream, including the environment of the closures used.
  • Fixed a bug in the implementation of the _CancelableStream class. The asBroadcastStream() method created a broadcast stream based on the inner stream, not the outer stream. The created stream was not a cancelable stream.

5.3.0 #

  • Fixed a bug in the withSubscriptionTracking() method of the StreamExtension extensions. The possibility of replacing the onDone and onError callbacks in a stream subscription was not taken into account. Setting those callbacks ​​to null resulted in the corresponding events (done, error) not being triggered.

5.2.0 #

  • Breaking change: Removed withCancellationHandler() and listenWithCancellationHandler() methods from StreamExtension extension.
  • Added withSubscriptionTracking() method to StreamExtension extensions. As a replacement for the removed withCancellationHandler() and listenWithCancellationHandler() methods.

5.1.0 #

  • Breaking change: Removed class ZoneStats. This functionality only slows down the execution of tasks.
  • Added method withCancellationHandler() to StreamExtension extension.
  • Added method listenWithCancellationHandler() to StreamExtension extension.

5.0.0 #

  • Breaking change: Removed deprecated class Throughput.
  • Breaking change: Removed deprecated class TokenBucket.
  • Breaking change: Code normalization, the state field of the Task class has been renamed to status.
  • Breaking change: Code normalization, the TaskState enum has been renamed to TaskStatus.
  • Breaking change: Code normalization, the completed value of the TaskStatus enum has been renamed to successful.
  • Breaking change: The isCompleted getter of the Task class has been renamed to isSuccessful.
  • Breaking change: The isStarted getter of the Task class has been removed.
  • Documentation has been added or changed.

4.6.0 #

  • Breaking change: The runCancelable() method of the CancellationToken class no longer throws a TaskCanceledException exception, in case the cancellation request occurred after the successful completion of the operation. Now the main purpose is to add and automatically remove a cancel handler in the token to cancel the operation. After successful completion of the operation, it is recommended to use token.throwIfCanceled() if necessary.
  • Changed example example_task_cancel_long_network.dart.
  • Changed example example_task_cancel_network.dart.
  • Changed example example_task_download_file.dart.
  • Changed example example.dart.

4.5.0 #

  • Fixed a bug in StreamExtension.listenWithCancellation(): The throwIfCancelled parameter has been renamed to throwIfCanceled.
  • Added method asCancelable() to StreamExtension extension.

4.4.0 #

  • Deprecated class TokenBucket.
  • Added method withCancellation() to Task class.
  • Added example example_task_cancel_waiting_for_non_cancelable_action.dart.
  • Added extension StreamExtension with listenWithCancellation() method.
  • Added method createLinkedTokenSource() to CancellationTokenSource class.

4.3.0 #

  • Several typos have been corrected.
  • Added example example_task_await_in_order_of_receipt.dart.
  • Added class TokenBucket.
  • Added class SpeedTest.
  • Deprecated class Throughput.
  • Added example example_token_bucker.dart.

4.2.0 #

  • Added method cancelAfter() to CancellationTokenSource class.
  • The operating algorithm of the TaskCompletionSource has been improved.

4.1.0 #

  • Changed example example_task_wait_in_different_ways.dart.
  • Added example example_task_stream.dart.
  • Added method whenEach() to Task class.
  • Added method delay() to Task class.
  • Breaking change: Code normalization, the cancelled identifiers have been renamed to canceled.
  • Breaking change: Code normalization, the cancellable identifiers have been renamed to cancelable.

4.0.0 #

  • Breaking change: Code cleanup, removed the following functions: runAndDetach(), runCancellable().
  • Breaking change: Code cleanup, removed the classes: CancellableStreamIterator.
  • Breaking change: Code normalization, renamed TaskCanceledError class to TaskCanceledException. Also, this class now implements the Exception interface and no longer extends the Error class.
  • Non-breaking change: The following methods now return Future<void> instead of void: Task.start(), PauseToken.pause(), PauseToken.resume().

3.8.0 #

  • Added method whenAny() to Task class.
  • Added method whenAll() to Task class.
  • Changed signature of waitAll() method of Task class to Future<void> waitAll<T>(List<Task<T>> tasks, {Progress<({int count, int total})>? progress}). Now, when specifying a progress parameter it is possible to track the progress of the wait operation.
  • Added class CountdownTimer

3.7.0 #

  • Changed signature of wait() method of PauseToken class to Future<void> wait({CancellationToken? token}). Now, when specifying a token parameter, the method can throw a TaskCanceledError exception.

3.6.0 #

  • Added method reacquire() to Lock class. This method is implemented exclusively to ensure fair operation of reacquiring the lock in condition variable in the wait() method.
  • Fixed a bug in ManualResetEvent.

3.5.0 #

  • Added method runCancellable() to CancellationToken class. The runCancellable() function now forwards execution to this method.
  • Added PauseToken class
  • Added Throughput class

3.4.0 #

  • Changed example example_task_cancel_long_network.dart.
  • Changed example example_task_cancel_network.dart.
  • Changed example example_task_cancel_during_stream_iteration.dart.
  • Added class Progress
  • Changed example example_task_download_file.dart.

3.3.0 #

  • Non-breaking changes: Handlers of the CancellationToken class can be asynchronous and now they are executed in the zone where the handlers were created via the scheduleMicrotask() call.
  • Fixed a bug in AutoResetEvent and ManualResetEvent.

3.2.0 #

  • Added example example_task_wait_in_different_ways.dart.
  • Added class ZoneStats
  • Added example example_task_zone_stats.dart.

3.1.0 #

  • Breaking change: Removed method runGuarded from class CancellationToken.
  • Added function runCancellable() to lib/src/task/cancellation.dart.
  • Added function runAndDetach() to lib/src/task/cancellation.dart.

3.0.0 #

  • Breaking change: The task immediately propagates an exception if it is an unhandled exception in the task zone. An unhandled exception in the task zone is considered to be an exception that occurs in the task zone after a task has completed.
  • Added method runGuarded() to class CancellationToken. Purpose: Perform asynchronous actions (especially when using I/O operations) with guaranteed protection from unhandled exceptions and "automatic" processing of task cancellation requests.
  • Added getter result to class Task.
  • Added example example_task_handle_unhandled_error.dart.
  • Added example example_task_result.dart.

2.11.0 #

The ConditionVariable.wait() implementation has been adjusted to make the implementation more consistent with the Moore monitor.

2.10.0 #

  • Breaking change: The ForEach class has been removed in favor of a more correct way to achieve the same result - by using the SteamIterator class.
  • Added class AutoResetEvent.
  • Added class ManualResetEvent.
  • Added example example_task_cancel_isolate.dart.
  • Added class CancellableStreamIterator.

2.9.0 #

  • Added class MultipleWriteSingleReadObject.
  • Added example example_multiple_write_single_read_object.dart.
  • Fixed typo in README.md

2.8.0 #

  • Changed the link to the image mutex.gif.
  • Removed unused code from the Lock class.
  • The algorithm for the ConditionVariable.tryWait() method has been corrected.

2.7.0 #

  • Fixed a bug with incorrect use of WaitQueue.
  • Fixed a bug in ConditionVariable.
  • Added image assets/images/mutex.gif.

2.6.0 #

  • Slightly improved ReentrantLock performance.
  • The internal algorithm for processing the Task result has been slightly changed.
  • Added getters for the Task, for each task state (eg. isCompleted for the TaskState.completed state).
  • Breaking change: The Synchronizer class has been renamed to Lock.

2.5.0 #

  • Slightly improved BinarySemaphore performance.
  • Slightly improved ReentrantLock performance.
  • Changed example example_task_cancel_long_network.dart.
  • Changed example example_task_cancel_network.dart.
  • Changed example example_task_cancel_await_for_stream_emulation.dart.
  • Breaking change: Removed Task.awaitFor method.
  • Added class ForEach.

2.4.0 #

  • Breaking change: Removed type parameter from ReentrantLock class.

2.3.0 #

  • Added table of contents in file README.md.
  • Added class ReentrantLock.
  • Added example example_reentrant_lock.dart.

2.2.0 #

  • Added an explanation of the operating principle and internal structure of the task.
  • Changed package description.
  • A unified mechanism for implementing a waiting queue has been added (WaitQueue).
  • Breaking change:The signatures of some synchronization primitives have been changed to consistently use wait queues. This applies to methods that implement waiting with a timeout (tryWait()).

2.1.0 #

  • Added example example_counting_semaphore.dart.
  • Added example example_task_cancel_await_for_stream.dart.
  • Added method static Task<void> awaitFor<R>(Stream<R> stream, CancellationToken token, bool Function(R) f).
  • Added class CountingSemaphore.
  • Added class: BinarySemaphore.
  • Breaking change: The functionality of the CancellationToken handler has been changed. Performance and usability have been improved, and most importantly, the restriction on linking to a single task has been lifted.
  • Added example example_task_cancel_during_sleep.dart.
  • Added example example_binary_semaphore.dart.
  • Added class Synchronizer.
  • Added class ConditionVariable.
  • Added example example_condition_variable.dart.

2.0.0 #

  • Breaking change: Removed support for unsafe task termination.
  • Added support for safe task cancellation.

1.2.0 #

  • Minor corrections have been made to the examples.

1.1.0 #

  • Fixed a bug that did not take into account that in Dart, a function cannot return a Future<Future<T>> result. Dart automatically flattens this value to Future<T>.
  • Changed signature of the following methods in the Task class: Future<Task<T>> run(), Future<void> start() to Task<T> run(), void start(). First method (run) was changed because Dart blocks Future<Task<T>> Task<T>.run) until the task completes, the second method (start) was changed to be consistent with the first.

1.0.0 #

  • Initial release.
2
likes
160
points
1.05k
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Cooperative multitasking using asynchronous tasks and synchronization primitives, with the ability to safely cancel groups of nested tasks performing I/O wait or listen operations.

Repository (GitHub)
View/report issues

Topics

#concurrency #cancellation #synchronization #mutex #streams

License

BSD-3-Clause (license)

Dependencies

meta, stack_trace

More

Packages that depend on multitasking