Dart API Referencedart:isolateSendPort

SendPort abstract class

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.

abstract class SendPort {

  /**
   * 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
   * dart2js 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]);

  /**
   * 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);

  /**
   * Tests whether [other] is a [SendPort] pointing to the same
   * [ReceivePort] as this one.
   */
  bool operator==(var other);

  /**
   * Returns an immutable hash code for this send port that is
   * consistent with the == operator.
   */
  int get hashCode;

}

Properties

final int hashCode #

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

int get hashCode;

Operators

bool operator ==(other) #

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

bool operator==(var other);

Methods

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);

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 dart2js 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]);