Mailbox class
Mailbox communication primitive.
This synchronization primitive allows a single producer to send messages to one or more consumers. Producer uses put to place a message into a mailbox which consumers can then take out.
Mailbox object can not be directly sent to other isolates via a
SendPort, but it can be converted to a Sendable<Mailbox> via
asSendable getter.
!!! WARNING !!! The Mailbox object is owned by the isolate that created it. You need to be certain that all producers and consumers have stopped before dereferencing the mailbox in the owning isolate, otherwise you may corrupt memory.
Constructors
- Mailbox()
Properties
-
asSendable
→ Sendable<
Mailbox> -
no setter
- count → int
-
The number of messages currently in the mailbox (0 or 1).
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
close(
) → void - Close a mailbox.
-
isClosed(
) → bool -
isEmpty(
) → bool -
isFull(
) → bool -
isOpen(
) → bool - Returns true if the mailbox is open.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
put(
Uint8List message) → void - Place a message into the mailbox if has space for it. If mailbox already contains a message the put will throw a MailBoxFullException exception. If mailbox is closed then put will throw MailBoxClosedException.
-
take(
{Duration? timeout}) → Uint8List - Take a message from the mailbox.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited