squadron library
Classes
- BuildOptions
- CastConverter
- Channel
- A Channel supports communication from a client to a platform worker. It is used to send a WorkerRequest to a platform worker.
- ConcurrencySettings
- Concurrency settings governing parallelization of workers in a WorkerPool.
- ContextAwareConverter
- Converter
- ExceptionManager
-
GenericMarshaler<
T> -
Base class to abstract
SinSquadronMarshaler<T, S>. -
IdentityMarshaler<
T> - Identity marshaler.
- Invoker
- IWorker
-
LocalWorker<
W> - Base local worker class.
- MarshalingContext
- Marshaling context. Context-aware marshalers can register marshaled / unmarshaled instances; if the same input is encountered, the same instance can be fetched from the context instead of marshaling/unmarshaling a fresh instance. Context-aware marshalers can be used where object identities matter. Additionally, they also help support serialization of instances that bear cyclical dependencies.
- NumConverter
- PerfCounter
- Simple performance counter to consolidate statistics about woker tast execution: total number of calls, total number of errors, total elapsed time, and max elapsed time.
- PerfCounterSnapshot
- A snapshot of a PerfCounter's values.
- SerializationContext
- Squadron
-
SquadronMarshaler<
T, S> -
Base class to serialize/deserialize data of type
Tto a transferable typeS. - SquadronMethod
- Annotation for service methods to be exposed by workers.
- SquadronService
- Annotation for service classes to be wrapped as workers.
-
StreamTask<
T> - Class representing a Task returning a stream of values.
- TargetPlatform
-
Task<
T> - Base worker task class
-
ValueTask<
T> - Class representing a Task returning a single value.
- Worker
- Base worker class.
- WorkerChannel
- A WorkerChannel supports communication from a platform worker to the client that posted the WorkerRequest. It is used to send WorkerResponse back to the client.
- WorkerClient
- Base class used to communicate with a Worker over a Channel.
-
WorkerPool<
W extends Worker> -
Worker pool responsible for instantiating, starting and stopping workers running in parallel.
A WorkerPool is also responsible for creating and assigning
WorkerTasks to Workers. - WorkerService
- Base class for a worker service.
- WorkerStat
- Base statistics for worker.
Mixins
- ServiceInstaller
- Extend this class or implement this interface in your worker service if it needs to take action when the worker thread is started or stopped.
Extension Types
- OperationsMap
- WorkerRequest
-
WorkerRequests are used to communicate from a client to a Worker.
Typically a WorkerRequest consists of a command ID and a list of
arguments. The command ID is used by the Worker to dispatch the
WorkerRequest to the method responsible for handling it.
The command's arguments are passed as a list and should only contain
primitive values or objects that can be transfered across workers. For
applications running on a VM platform, Dart objects should be safe
according to Dart's documentation of SendPort.send.
WorkerRequestImplalso implements specific requests used for worker startup, stream/token cancelation, worker termination... - WorkerResponse
-
WorkerResponses are used to communicate from Workers to clients and
carry a single piece of data. Future-based services simply return a
single WorkerResponse with the result. Streaming services will return
one WorkerResponses for each stream item and mmust send a
WorkerResponse.closeStreammessage to indicate completion. WorkerResponses can also send error messages and log events.
Extensions
-
CompleterSafeExt
on Completer<
T> -
ConcurrencySettingsExt
on WorkerPool<
Worker> -
ControllerSafeExt
on StreamController<
T> - ConverterExt on MarshalingContext?
- Make MarshalingContext? a converter
- HexExt on int
- TargetPlatformExt on int
-
WorkerStatsExt
on Iterable<
WorkerStat>
Constants
- localService → const SquadronService
- squadronMethod → const SquadronMethod
- vmService → const SquadronService
Functions
-
run(
WorkerInitializer initializer, [WorkerRequest? command]) → void -
Instantiates a WorkerService via the
initializerand installs the service in a platform worker. Thecommandargument is ignored on Web platforms. On native platforms, thecommandargument must be set to the Isolate's startup parameter.
Typedefs
-
Cast<
T> = T Function(dynamic) - CommandHandler = FutureOr Function(WorkerRequest req)
- EntryPoint = EntryPoint
- PlatformChannel = PlatformChannel
- PlatformThread = PlatformThread
- PlatformThreadHook = PlatformThreadHook
- PostRequest = void Function(WorkerRequest req)
- StreamCanceler = void Function()
- WorkerExceptionDeserializer = WorkerException? Function(List props)
-
WorkerFactory<
W> = W Function(ExceptionManager) -
WorkerInitializer
= FutureOr<
WorkerService> Function(WorkerRequest startRequest)
Exceptions / Errors
- SquadronCanceledException
- SquadronCanceledExceptions
- SquadronError
- Squadron Error
- SquadronException
- Base abstract class for exceptions in Squadron.
- SquadronTimeoutException
- TaskCanceledException
- TaskTerminatedException
- WorkerException
- Exception to keep track of errors encountered in a worker.