DownloadIsolatePool class
Manages a pool of isolates for handling concurrent download tasks. Responsible for task scheduling, isolate creation, task binding, and communication between the main isolate and download isolates.
Constructors
- DownloadIsolatePool.new({int poolSize = MAX_ISOLATE_POOL_SIZE})
-
Constructs a DownloadIsolatePool with the specified
poolSize
. Throws an ArgumentError if the pool size is less than or equal to zero.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
-
isolateList
→ List<
DownloadIsolateInstance> -
Returns the list of all isolate instances in the pool.
no setter
- poolSize → int
-
Returns the maximum number of isolates in the pool.
no setter
-
prepareTasks
→ List<
DownloadTask> -
Returns the list of tasks that are not currently downloading.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
streamController
→ StreamController<
DownloadTask> -
Returns the stream controller for task updates.
no setter
-
taskList
→ List<
DownloadTask> -
Returns the list of all tasks in the pool.
no setter
Methods
-
addTask(
DownloadTask task) → Future< DownloadTask> -
Adds a new
task
to the pool, creating a cache directory if needed. -
dispose(
) → Future< void> - Disposes the pool, cancels all subscriptions, kills all isolates, closes ports and the stream controller, and resets task IDs.
-
executeTask(
DownloadTask task) → Future< DownloadTask> -
Executes a
task
, replacing any existing lower-priority task with the same cache key. Schedules the isolate pool for task execution. -
findIsolateByTaskId(
String taskId) → DownloadIsolateInstance? -
Finds an isolate instance by the associated task's
taskId
. -
findTaskById(
String taskId) → DownloadTask? -
Finds a task in the pool by its
taskId
. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyIsolate(
String taskId, DownloadStatus message) → void -
Notifies the isolate associated with
taskId
to update its status tomessage
. If the isolate is not found and the message is to start downloading, resumes the task. -
resumeTask(
DownloadTask task) → Future< DownloadTask> -
Resumes a paused or new
task
by binding it to an available isolate. -
roundIsolate(
) → Future< void> - Schedules the pool to run tasks, ensuring only one thread runs this logic at a time.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited