XZMultithreadOptions<T> class

Turns an XZDecoder call into a decode that runs on isolates.

Passing one of these switches that single call into multithreaded mode. The method returns immediately and the result arrives through onDone instead of the return value, because an isolate cannot be waited on synchronously.

final completer = Completer<Uint8List>();
XZDecoder().decodeBytes(compressed,
    multithread: XZMultithreadOptions(
      onDone: completer.complete,
      onError: (error, _) => completer.completeError(error),
    ));
final data = await completer.future;

The type argument follows the method being called: Uint8List for XZDecoder.decodeBytes and bool for XZDecoder.decodeStream. It is inferred from the method, so writing XZMultithreadOptions(onDone: (result) { ... }) is enough.

Constructors

XZMultithreadOptions({required void onDone(T result), void onError(Object error, StackTrace stackTrace)?, int? workers, int? memoryBudget, int fileReadBufferSize = 8 * 1024 * 1024})
const

Properties

fileReadBufferSize → int
Buffer a worker reads its block through, in bytes.
final
hashCode → int
The hash code for this object.
no setterinherited
memoryBudget → int?
Ceiling on the memory the isolates may hold at once, in bytes.
final
onDone → void Function(T result)
Called exactly once with the result of the decode.
final
onError → void Function(Object error, StackTrace stackTrace)?
Called instead of onDone when the decode fails.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
workers → int?
Maximum number of isolates to decode on.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited