LevitTaskEngine class
A standalone engine for named, cancellable asynchronous work.
The engine provides global priority/concurrency scheduling while conflict policies define ordering for submissions that share a logical task ID.
- Implemented types
Constructors
- LevitTaskEngine({required int maxConcurrent, LevitTaskCacheProvider? cacheProvider, void onTaskError(Object error, StackTrace stackTrace)?, void onTaskEvent(LevitTaskEvent event)?, String ownerPath = '?'})
-
Creates a task engine with
maxConcurrentworkers.
Properties
- cacheProvider ↔ LevitTaskCacheProvider
-
The cache provider used by this engine.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- maxConcurrent ↔ int
-
The maximum number of concurrent admitted executions.
getter/setter pair
- onTaskError ↔ void Function(Object error, StackTrace stackTrace)?
-
Optional global error handler for terminal task failures.
getter/setter pair
- onTaskEvent ↔ void Function(LevitTaskEvent event)?
-
Optional local lifecycle instrumentation callback.
getter/setter pair
- ownerPath ↔ String
-
Diagnostic path attached to task events.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
cancel(
String id) → void -
Cooperatively cancels all outstanding executions for logical
id. -
cancelAll(
) → void - Cooperatively cancels every outstanding execution.
-
cancelExecution(
String executionId) → bool - Cooperatively cancels one admitted execution.
-
config(
{int? maxConcurrent, LevitTaskCacheProvider? cacheProvider, String? ownerPath, void onTaskError(Object error, StackTrace stackTrace)? = _onTaskErrorUnset, void onTaskEvent(LevitTaskEvent event)? = _onTaskEventUnset}) → void - Dynamically updates engine configuration.
-
dispose(
) → void -
Releases resources held by this object.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
schedule<
T> (FutureOr< T> task(LevitTaskContext context), {String? id, TaskPriority priority = TaskPriority.normal, TaskConflictPolicy conflictPolicy = TaskConflictPolicy.reject, int retries = 0, Duration? retryDelay, bool useExponentialBackoff = true, void onError(Object error, StackTrace stackTrace)?, TaskCachePolicy<T> ? cachePolicy, void onStart()?, void onSuccess(T result)?, void onProgress(double progress)?, void onCancel()?, void onEvent(LevitTaskEvent event)?, LevitTaskMetadata? metadata, String? debugName}) → Future<T?> -
Schedules
taskand returns only its eventual result. -
scheduleIsolate<
I, T> (LevitIsolateTask< I, T> task, I input, {String? id, TaskPriority priority = TaskPriority.normal, TaskConflictPolicy conflictPolicy = TaskConflictPolicy.reject, int retries = 0, Duration? retryDelay, bool useExponentialBackoff = true, void onError(Object error, StackTrace stackTrace)?, TaskCachePolicy<T> ? cachePolicy, void onStart()?, void onSuccess(T result)?, void onProgress(double progress)?, void onCancel()?, void onEvent(LevitTaskEvent event)?, LevitTaskMetadata? metadata, String? debugName}) → Future<T?> -
Schedules a message-safe top-level/static
taskin a new isolate. -
submit<
T> (FutureOr< T> task(LevitTaskContext context), {String? id, TaskPriority priority = TaskPriority.normal, TaskConflictPolicy conflictPolicy = TaskConflictPolicy.reject, int retries = 0, Duration? retryDelay, bool useExponentialBackoff = true, void onError(Object error, StackTrace stackTrace)?, TaskCachePolicy<T> ? cachePolicy, void onStart()?, void onSuccess(T result)?, void onProgress(double progress)?, void onCancel()?, void onEvent(LevitTaskEvent event)?, LevitTaskMetadata? metadata, String? debugName}) → LevitTaskExecution<T> -
Submits
taskand returns its execution identity and result. -
submitIsolate<
I, T> (LevitIsolateTask< I, T> task, I input, {String? id, TaskPriority priority = TaskPriority.normal, TaskConflictPolicy conflictPolicy = TaskConflictPolicy.reject, int retries = 0, Duration? retryDelay, bool useExponentialBackoff = true, void onError(Object error, StackTrace stackTrace)?, TaskCachePolicy<T> ? cachePolicy, void onStart()?, void onSuccess(T result)?, void onProgress(double progress)?, void onCancel()?, void onEvent(LevitTaskEvent event)?, LevitTaskMetadata? metadata, String? debugName}) → LevitTaskExecution<T> -
Submits a message-safe top-level/static
taskin a new isolate. -
toString(
) → String -
A string representation of this object.
inherited
-
updateProgress(
String id, double progress) → void -
Reports progress for the latest running execution of logical
id.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited