async_task 1.2.0
async_task: ^1.2.0 copied to clipboard
Asynchronous tasks and parallel executors (similar to thread pools) for all Dart platforms (transparently), without having to deal with `Isolate` complexity.
1.2.0 #
-
lib/src/async_task_isolate.dart:AsyncExecutor.executewhile closing, oncecloseis no longer waiting for executing tasks (theIsolates are being closed), now throws anAsyncExecutorClosedError, as afterclose. Previously, with noIsolatespawned yet, it failed with anIntegerDivisionByZeroException, and otherwise the task was submitted to a closingIsolate(never completing). A task executed whileclosewaits for the executing tasks is still accepted (and waited for).AsyncExecutor.closealso waits for the tasks executed while it was waiting for the executing tasks.- A task that can't be sent to the
Isolate(parameters that can't be sent between isolates, or aSharedDataserialization error) now completes with anAsyncExecutorError(AsyncTask submit error). Previously it never completed andAsyncExecutor.closenever returned. - A task with a throwing
parameters()(orsharedData()) no longer preventsAsyncExecutor.closefrom returning, and releases its channel port.
-
lib/src/async_task_base.dart:AsyncExecutor: a task executed before the executor is started, failing to be submitted, now completes itsFuturewith the error (was an unhandled error)._Isolate: releases the task channel port of a task failing before its execution (for example,instantiatethrowing in theIsolate), and the port of a task without a channel in theIsolate(channelInstantiatorreturningnull) but with a channel in the main side.- A task that fails in an
Isolatenow has itsinitTimeandendTime(as with the generic executor). They're stillnullif the task failed before its execution (resolving itsSharedDataor instantiating it in theIsolate).
-
lib/src/async_task_shared_data.dart:SerializableData.copyGeneric:List,SetandIterablecopies keep the element type (were copied withdynamicelements, failing the cast to a typed collection, like aList<Object>).SerializableData.copyGeneric:MapandMapEntrycopies keep the key/value types when they are basic types (String,int,double,num,bool, also nullable),ObjectorObject?/dynamic. For other types (likeMap<String, List<int>>) aStateErroris thrown if the copy (with the closest supported types) is not of the requested type. AMapEntrywith immutable key and value is returned as is.SerializableData.copyGeneric: supportsnull(also as a collection element).
-
Tests:
async_task_isolate_integration_test.dart:executewhile closing (with and withoutIsolates), channel port leak of tasks failing to instantiate (viavm_service), execution times of failed tasks, tasks with parameters that can't be sent to theIsolateor with throwingparameters().async_task_stress_test.dart: failed tasks in anIsolatehave execution times (the file was also re-formatted bydart format).async_task_shared_data_test.dart: typed collections copies.
1.1.5 #
- async_extension: ^1.2.24
1.1.4 #
-
lib/src/async_task_isolate.dart:_Isolate: an error while resolving a task'sSharedDatain theIsolate(loadSharedDatathrowing or returningnull, or a task type not registered) now completes the task with anAsyncExecutorError. Previously the error was unhandled in theIsolateport handler, killing theIsolate: the task never completed andAsyncExecutor.closenever returned._Isolate: a failed request of a missingSharedData(to the main side) no longer leaves a stale pending request: the next task requests it again._Isolate: the task channel port is sent to the main side only after the task channel is initialized. When the task execution was delayed by aSharedDatarequest to the main side, channel messages sent by the main side in the meantime were lost (the task waited forever)._Isolate: releases the task channel port of a task that failed resolving itsSharedData.
-
Tests:
- New
async_task_stress_test.dart(VM and Web): hundreds of tasks withparallelism0/1/4, sequential and not, mixed sync/async/throwing tasks, results order and identity,closewhile tasks are queued or running,executewhile closing,SharedDatareuse and dispose across many tasks and bidirectional channel messages under load. - New
async_task_isolate_integration_test.dart(VM):SharedDataload failures and the request of a missingSharedDatafrom the main side, dispose between queued tasks, concurrent tasks with newSharedDataandIsolatetermination on close (viavm_service). async_task_counter_test.dart: replaced the wall-clock assertions (execution and total time thresholds) with assertions on the ordering of the execution intervals (concurrent vs. sequential execution).
- New
1.1.3 #
-
lib/src/async_task_base.dart:_AsyncExecutorSingleThread.execute(used withparallelism: 0and on the Web): marks the task as submitted immediately, as theIsolateexecutor does, so a repeatedAsyncExecutor.executeof the same task no longer executes it twice.AsyncTask: a throwingOnFinishAsyncTasktrigger now logs its own error (was logging the task error).
-
lib/src/async_task_shared_data.dart:SerializableData.copyGeneric: fixedInt16ListandFloat64Listcopies (were creating anInt8List/Float32Listand failing).SerializableData.copyGeneric,serializeGeneric,deserializeGeneric:MapEntrynow keeps itsvalue(thekeywas used for both).SerializableData.deserializeGeneric:dynamic/Objecttypes return the value as is, allowing the deserialization of untypedList,Set,IterableandMapEntryelements.
-
lib/src/async_task_extension.dart:ListDoubleExtension.toFloat64x2List: fixed index computation (was failing for lists with more than 2 values).
-
lib/src/async_task_shared_pointer.dart:SharedPointerAddress.serialize: fixed the order of the serialized fields, matchingdeserialize.
-
lib/src/async_task_channel.dart:AsyncTaskChannelconstructor: uses a private initializing formal (the named parameter is stillmessageHandler).
-
Removed library names (
library;) and fixed dartdoc references. -
dart formatwith the Dart 3.13 style. -
Tests:
- New
async_task_executor_test.dart(VM and Web),async_task_isolate_test.dart(VM) andasync_task_shared_data_test.dart. - Close all executors at the end of the tests.
- New
-
pubspec.yaml:- Updated SDK constraint to
^3.13.0. - Updated dependencies:
async_extensionto ^1.2.23ffito ^2.2.0
- Updated dev_dependencies:
lintsto ^6.1.0testto ^1.33.0dependency_validatorto ^5.1.0coverageto ^1.16.0vm_serviceto ^15.4.0
- Updated SDK constraint to
-
.github/workflows/dart.yml:actions/checkout@v7.codecov/codecov-action@v7.
1.1.2 #
-
lib/src/async_task_isolate.dart:_Isolateclass_handleMessagemethod: removed default case that threwStateErroron unhandled messages (not needed in Dart 3.6+).
-
pubspec.yaml:- Updated SDK constraint to
>=3.6.0 <4.0.0. - Updated dependencies:
collectionto ^1.19.1async_extensionto ^1.2.20ffito ^2.1.5
- Updated dev_dependencies:
testto ^1.29.0coverageto ^1.15.0
- Updated SDK constraint to
1.1.2.beta #
- async_extension: ^1.2.12
- ffi: ^2.1.3
- test: ^1.25.8
- coverage: ^1.9.2
1.1.1 #
-
Optimize
AsyncTaskLoggerCaller:- Avoid
Stringbuild when logging is disabled.
- Avoid
-
Optimize
async_task_isolate.dart:- Improve message objects, to allow immutable detection.
-
AsyncTask:- Improve error handling and error response from
Isolate.
- Improve error handling and error response from
-
sdk: '>=3.2.0 <4.0.0'
-
async_extension: ^1.2.5
-
lints: ^3.0.0
-
test: ^1.24.9
-
dependency_validator: ^3.2.3
-
coverage: ^1.7.1
-
vm_service: ^13.0.0
1.1.0 #
-
sdk: '>=3.0.0 <4.0.0'
-
collection: ^1.18.0
-
async_extension: ^1.2.4
-
ffi: ^2.1.0
-
lints: ^2.1.1
-
test: ^1.24.6
-
coverage: ^1.6.3
-
vm_service: ^11.9.0
1.0.20 #
README.md:- Fix GitHub CI badge.
- Added
parallelismexplanation.
- test: ^1.22.1
1.0.19 #
- Update GitHub CI.
- Added tests in chrome.
- sdk: '>=2.17.0 <3.0.0'
- collection: ^1.17.0
- async_extension: ^1.0.12
- ffi: ^2.0.1
- lints: ^2.0.1
- test: ^1.22.0
- dependency_validator: ^3.2.2
- coverage: ^1.6.1
- vm_service: ^9.4.0
1.0.18 #
AsyncExecutor:- Added field
name(for debug purposes). - Now detects Isolate starting timeout.
- Added field
1.0.17 #
- New
AsyncExecutorThreadInfoandAsyncThreadInfo. - Improved
AsyncTaskChannelclose behavior. - Reduced allocation of closures and
Futures to improve GC performance. AsyncTask:- Added trigger list
addOnFinishAsyncTask, to avoidFutures.
- Added trigger list
1.0.16 #
SharedPointerBytes:- Expose
bytesandbyteData.
- Expose
1.0.15 #
- Added
SharedPointer: shared memory area betweenIsolates. - ffi: ^1.1.2
1.0.14 #
- Fix issue when reusing
_ReceivePort. - Optimize imports.
1.0.13 #
AsyncTaskChannel:- Added
idto help debugging. - Added non-blocking
readMessage. - Added
messageQueueLengthandmessageQueueIsEmpty.
- Added
AsyncTaskChannelPort:- Added
idto help debugging. - Added
readSyncandmessageQueueLength.
- Added
- Fixed issue executing tasks in a not start
AsyncExecutorthat is sequencial. - async_extension: ^1.0.9
- test: ^1.19.5
- dependency_validator: ^3.1.2
1.0.12 #
- Migrate from
pedantictolints. - Using Dart coverage.
- async_extension: ^1.0.8
- lints: ^1.0.1
- coverage: ^1.0.3
1.0.11 #
- Improve tests.
- Only export
async_extensionon libraryasync_task_extension.dart.
1.0.10 #
- Optimize
asyncmethods withasync_extension. - Improve tests.
- async_extension: ^1.0.4
1.0.9 #
- Ensure that all ports are closed after close executors.
README.md:- Fix typo.
- Improve channel usage description.
- Move
IterableFutureOrExtensionandIterableFutureExtensionto packageasync_extension.- async_extension: ^1.0.3
1.0.8 #
- Fix isolate message of a task without
SharedData. - Improved tests scenarios.
1.0.7 #
- Small fix in README.
- Small fix in example.
1.0.6 #
- Added
AsyncTaskChannelfor messages communication with tasks during execution. - Added
AsyncExecutorStatus. AsyncExecutor: optimize to avoid creating of futures while executing/processing a task.- Improved README.
1.0.5 #
- Added
AsyncTaskPlatformandAsyncTaskPlatformType. AsyncTask:- Optimize
taskType - Optimize
executeto use lessasyncoperations.
- Optimize
- Added
AsyncExecutorSharedDataInfoto reportSharedDatainformation. AsyncExecutor:- New constructor parameter
parallelismPercentage. - Optimize
execute,executeAllandexecuteAllAndWaitResultsto dispatch less asyn operations. - Added
disposeSharedDataanddisposeSharedDataInfo.
- New constructor parameter
- Extensions:
- Added
IterableFutureOrExtensionandIterableFutureExtension.
- Added
_AsyncExecutorMultiThread:- Optimized to use less
asyncoperations. - Using
_RawReceivePortPoolto optimize ports. - Optimized to pre send
SharedData.
- Optimized to use less
- Added
_RawReceivePortPool: pool of reusable_ReceivePort. - Added
_ReceivePort: an optimizedRawReceivePort.
1.0.4 #
AsyncTask:- Allow multiple
SharedData: Optional methodsharedDatanow returns aMap<String,SharedData>.
- Allow multiple
1.0.3 #
AsyncExecutor:- Fix
closeoperation while tasks are being executed.
- Fix
1.0.2 #
- Added
SharedData, to optimize data sharing between tasks and threads/isolates. AsyncExecutor: addedcloseto stop and finalize an executor.- Added collections extensions:
ListExtension,MapExtension,SetExtension,IterableExtension.
1.0.1 #
- Fix
pubspec.yamldescription length. - Improve
README.mddescription.
1.0.0 #
- Implemented
AsyncTaskwithstatus,resultandexecutionTime. AsyncExecutorwith implementations based ondart:isolateanddart:async.- Initial version.