General interface for all parallelization implementations.
Args
Generic | Description |
---|---|
I |
Input Type |
O |
Output Type |
CR |
Common Resource Record |
Note
-
Things like creating a HttpClient takes quiet a bit of time, so closing/reopening it each input is a bad idea. So, instead you create a common resource record in the setupProcess to bundle such high-cost setup operations. The output will be passed to all calls of processInput.
// Generate high-cost resources like HttpClient. // Creating a "record" with field names. var commonResources = (id: 10, name: 'Example', client: httpClient);
-
You destructure the record in processInput to access the high-cost resources while processing inputs.
// Full unpacking of a record. var (id, name, client) = commonResourceRecord; // field access of a record. var client = commonResourceRecord.client; // Do Processing
-
The shutdownProcess is used to clean up resources after processing is done.
- Implementers
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
-
processingIsComplete
→ Future<
void> -
Returns
null
when all processing is completed.no setter -
processInput
→ Future<
O> Function(I input, CR commonResourceRecord) -
Callback used for processing individual inputs sent to the spawned process.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
setupProcess
→ Future<
CR> Function() -
Generate common resources required to process individual inputs. The outputs are passed to all
calls of processInput.
no setter
-
shutdownProcess
→ Future<
void> Function(CR commonResourceRecord) -
Callback used for cleaning up any resources generated in setupProcess after processing
is done.
no setter
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
process(
I input) → Future< O> - Process the given input in a the spawned process.
-
shutdownNow(
) → Future< void> - Kill the spawned process immediately irrespective of weather the current inputs are processed or not.
-
shutdownOnCompletion(
) → Future< void> - Kill the spawned process after processing current items in queue.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited