Movatterモバイル変換


[0]ホーム

URL:


menu
  1. Dart
  2. dart:isolate
  3. Isolate class
Isolate
description

Isolate classfinal

An isolated Dart execution context.

All Dart code runs in an isolate, and code can access classes and valuesonly from the same isolate. Different isolates can communicate by sendingvalues through ports (seeReceivePort,SendPort).

AnIsolate object is a reference to an isolate, usually different fromthe current isolate.It represents, and can be used to control, the other isolate.

When spawning a new isolate, the spawning isolate receives anIsolateobject representing the new isolate when the spawn operation succeeds.

Isolates run code in its own event loop, and each event may run smaller tasksin a nested microtask queue.

AnIsolate object allows other isolates to control the event loopof the isolate that it represents, and to inspect the isolate,for example by pausing the isolate or by getting events when the isolatehas an uncaught error.

ThecontrolPort identifies and gives access to controlling the isolate,and thepauseCapability andterminateCapability guard accessto some control operations.For example, callingpause on anIsolate object created without apauseCapability, has no effect.

TheIsolate object provided by a spawn operation will have thecontrol port and capabilities needed to control the isolate.New isolate objects can be created without some of these capabilitiesif necessary, using theIsolate.new constructor.

AnIsolate object cannot be sent over aSendPort, but the control portand capabilities can be sent, and can be used to create a new functioningIsolate object in the receiving port's isolate.

Constructors

Isolate(SendPortcontrolPort, {Capability?pauseCapability,Capability?terminateCapability})
Creates a newIsolate object with a restricted set of capabilities.

Properties

controlPortSendPort
Control port used to send control messages to the isolate.
final
debugNameString?
The name of theIsolate displayed for debug purposes.
no setter
errorsStream
Returns a broadcast stream of uncaught errors from the isolate.
no setter
hashCodeint
The hash code for this object.
no setterinherited
pauseCapabilityCapability?
Capability granting the ability to pause the isolate.
final
runtimeTypeType
A representation of the runtime type of the object.
no setterinherited
terminateCapabilityCapability?
Capability granting the ability to terminate the isolate.
final

Methods

addErrorListener(SendPortport)→ void
Requests that uncaught errors of the isolate are sent back toport.
addOnExitListener(SendPortresponsePort, {Object?response})→ void
Requests an exit message onresponsePort when the isolate terminates.
kill({intpriority =beforeNextEvent})→ void
Requests the isolate to shut down.
noSuchMethod(Invocationinvocation)→ dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pause([Capability?resumeCapability])Capability
Requests the isolate to pause.
ping(SendPortresponsePort, {Object?response,intpriority =immediate})→ void
Requests that the isolate sendresponse on theresponsePort.
removeErrorListener(SendPortport)→ void
Stops listening for uncaught errors from the isolate.
removeOnExitListener(SendPortresponsePort)→ void
Stops listening for exit messages from the isolate.
resume(CapabilityresumeCapability)→ void
Resumes a paused isolate.
setErrorsFatal(boolerrorsAreFatal)→ void
Sets whether uncaught errors will terminate the isolate.
toString()String
A string representation of this object.
inherited

Operators

operator ==(Objectother)bool
The equality operator.
inherited

Static Properties

currentIsolate
AnIsolate object representing the current isolate.
no setter
packageConfigFuture<Uri?>
The location of the package configuration file of the current isolate.
no setter
packageConfigSyncUri?
The location of the package configuration file of the current isolate.
no setter

Static Methods

exit([SendPort?finalMessagePort,Object?message])→ Never
Terminates the current isolate synchronously.
resolvePackageUri(UripackageUri)Future<Uri?>
Resolves apackage: URI to its actual location.
resolvePackageUriSync(UripackageUri)Uri?
Resolves apackage: URI to its actual location.
run<R>(FutureOr<R>computation(), {String?debugName})Future<R>
Runscomputation in a new isolate and returns the result.
spawn<T>(voidentryPoint(Tmessage),Tmessage, {boolpaused =false,boolerrorsAreFatal =true,SendPort?onExit,SendPort?onError,String?debugName})Future<Isolate>
Spawns an isolate that shares the same code as the current isolate.
spawnUri(Uriuri,List<String>args,dynamicmessage, {boolpaused =false,SendPort?onExit,SendPort?onError,boolerrorsAreFatal =true,bool?checked,Map<String,String>?environment,Uri?packageRoot,Uri?packageConfig,boolautomaticPackageResolution =false,String?debugName})Future<Isolate>
Spawns an isolate running the script file specified byuri.

Constants

beforeNextEvent→ constint
Argument toping andkill: Ask for action before the next event.
immediate→ constint
Argument toping andkill: Ask for immediate action.
  1. Dart
  2. dart:isolate
  3. Isolate class
dart:isolate library

[8]ページ先頭

©2009-2025 Movatter.jp