Dart API Referencedart:isolateSendPort

SendPort Interface

SendPorts are created from ReceivePorts. Any message sent through a SendPort is delivered to its respective ReceivePort. There might be many SendPorts for the same ReceivePort.

SendPorts can be transmitted to other isolates.

Extends

Hashable

Methods

Code Future call(message) #

Sends a message to this send port and returns a Future of the reply. Basically, this internally creates a new receive port, sends a message to this send port with replyTo set to such receive port, and, when a reply is received, it closes the receive port and completes the returned future.

Future call(var message);

Code int hashCode() #

Returns an immutable hash code for this send port that is consistent with the == operator.

int hashCode();

Code bool operator ==(other) #

Tests whether other is a SendPort pointing to the same ReceivePort as this one.

bool operator==(var other);

Code void send(message, [SendPort replyTo]) #

Sends an asynchronous message to this send port. The message is copied to the receiving isolate. If specified, the replyTo port will be provided to the receiver to facilitate exchanging sequences of messages.

The content of message can be: primitive values (null, num, bool, double, String), instances of SendPort, and lists and maps whose elements are any of these. List and maps are also allowed to be cyclic.

In the special circumstances when two isolates share the same code and are running in the same process (e.g. isolates created via spawnFunction), it is also possible to send object instances (which would be copied in the process). This is currently only supported by the dartvm. For now, the frog compiler only supports the restricted messages described above.

Deprecation note: it is no longer valid to transmit a ReceivePort in a message. Previously they were translated to the corresponding send port before being transmitted.

void send(var message, [SendPort replyTo]);