@@ -563,9 +563,9 @@ class Isolate {
563
563
/// This operation is potentially dangerous and should be used judiciously.
564
564
/// The isolate stops operating *immediately*. It throws if the optional
565
565
/// [message] does not adhere to the limitations on what can be sent from one
566
- /// isolate to another. It also throws if a [finalMessagePort] is associated
567
- /// with an isolate spawned outside of current isolate group, spawned via
568
- /// [spawnUri] .
566
+ /// isolate to another (see [SendPort.send] for more details). It also throws
567
+ /// if a [finalMessagePort] is associated with an isolate spawned outside of
568
+ /// current isolate group, spawned via [spawnUri] .
569
569
///
570
570
/// If successful, a call to this method does not return. Pending `finally`
571
571
/// blocks are not executed, control flow will not go back to the event loop,
@@ -575,9 +575,9 @@ class Isolate {
575
575
/// code will run in the isolate.)
576
576
///
577
577
/// If [finalMessagePort] is provided, and the [message] can be sent through
578
- /// it, then the message is sent through that port as the final operation of
579
- /// the current isolate. The isolate terminates immediately after
580
- /// that [SendPort.send] call returns.
578
+ /// it (see [SendPort.send] for more details), then the message is sent
579
+ /// through that port as the final operation of the current isolate. The
580
+ /// isolate terminates immediately after that [SendPort.send] call returns.
581
581
///
582
582
/// If the port is a native port -- one provided by [ReceivePort.sendPort] or
583
583
/// [RawReceivePort.sendPort] -- the system may be able to send this final
@@ -599,9 +599,10 @@ class Isolate {
599
599
/// when sent.
600
600
abstract class SendPort implements Capability {
601
601
/// Sends an asynchronous [message] through this send port, to its
602
- /// corresponding ` ReceivePort` .
602
+ /// corresponding [ ReceivePort] .
603
603
///
604
- /// The content of [message] can be:
604
+ /// The transitive object graph of [message] can contain the following
605
+ /// objects:
605
606
/// - [Null]
606
607
/// - [bool]
607
608
/// - [int]
@@ -612,14 +613,34 @@ abstract class SendPort implements Capability {
612
613
/// - [SendPort]
613
614
/// - [Capability]
614
615
///
615
- /// In the special circumstances when two isolates share the same code and are
616
- /// running in the same process (e.g. isolates created via [Isolate.spawn] ),
617
- /// it is also possible to send object instances (which would be copied in the
618
- /// process).
619
- ///
620
- /// The send happens immediately and doesn't block. The corresponding receive
616
+ /// If the sender and receiver isolate share the same code (e.g. isolates
617
+ /// created via [Isolate.spawn] ), the transitive object graph of [message] can
618
+ /// contain any object, with the following exceptions:
619
+ ///
620
+ /// - Objects with native resources (subclasses of e.g.
621
+ /// `NativeFieldWrapperClass1`). A [Socket] object for example referrs
622
+ /// internally to objects that have native resources attached and can
623
+ /// therefore not be sent.
624
+ /// - [ReceivePort]
625
+ /// - [DynamicLibrary]
626
+ /// - [Pointer]
627
+ /// - [UserTag]
628
+ /// - `MirrorReference`
629
+ ///
630
+ /// Apart from those exceptions any object can be sent. Objects that are
631
+ /// identified as immutable (e.g. strings) will be shared whereas all other
632
+ /// objects will be copied.
633
+ ///
634
+ /// The send happens immediately and may have a linear time cost to copy the
635
+ /// transtive object graph. The send itself doesn't block (i.e. doesn't wait
636
+ /// until the receiver has received the message). The corresponding receive
621
637
/// port can receive the message as soon as its isolate's event loop is ready
622
638
/// to deliver it, independently of what the sending isolate is doing.
639
+ ///
640
+ /// Note: Due to an implementation choice the Dart VM made for how closures
641
+ /// represent captured state, closures can currently capture more state than
642
+ /// they need, which can cause the transitive closure to be larger than
643
+ /// needed. Open bug to address this: http://dartbug.com/36983
623
644
void send (Object ? message);
624
645
625
646
/// Tests whether [other] is a [SendPort] pointing to the same
0 commit comments