Вы находитесь на странице: 1из 4

Rust Runtime - Illustrated Rev 1

Weak Reference A direct pointer reference to an object. Generally used when


the object is guaranteed to be alive.

Strong Reference A ref counted reference to an object (the source ref counts
up the destination).

Indicates object ownership.


Owned by X X

A local proxy object for a remote object. Proxies are used as


Proxy for X, p(X) a safety mechanism in order to access remote objects in a
thread safe way. Proxies may either hold a weak, or strong
reference to the remote object.
Ports and Channels Sending Between
Thread Domains
Channel X Channel is cloned.

Messages are buffered in the


target port's Remote Channel.
upcall_send()

Port Channel X' No buffering happens in the sender, channels are


automatically flushed using message passing.
send data_msg
B
Task A Task B recv data_msg

A weak reference between ports and channels means


Implemented as a circular either can be dropped at any time. The port may drop
buffer. before the channel does, or vice versa. If the port drops, Task A Task B
any buffered data in the associated channels is dropped
on the floor. If a channel drops first, the owning task
blocks until all of its data is drained by the port. Receiving Between
Sending
Thread Domains
Channel Sending is asynchronous. Channels are buffered on the

(same as here)
sender side, and resized on demand.

Receiving
Channel 0
Receiving is synchronous. An associated channel is chosen
randomly and dequeued. If no data is available, the receiving
task blocks and yields. If blocked, the task is awoken by a Port Channel 1
sending task, in this case sending happens through a
rendezvous ptr.

Channel 2

Remote Channel

Messages sent from other thread


domains are buffered in here.
Task Messaging (Inter-Domain)
Implemented as a lock
free queue.

Message Queue Message Queue

Task A Task A

Each domain maintains a cache


Proxy Cache Proxy Cache of proxy objects, one for each
object outside of its domain.

Domain X Domain Y

Rust Message Rust messages are allocated


and enqueued on the
receiver side in a message
queue.
Source Task Proxy Message

Receiver

Proxy objects are used to mitigate access to objects owned by other thread or process
domains. The receiver task maintains a proxy for the source task, and uses it whenever it
needs to communicate back to the source task.

For safety, messages can only ever be sent via proxy objects.
Join (Intra-Domain)

Same as below, except that no messages are


necessary.

Inter-Domain

Upon receiving a join_msg, task B adds A to a


upcall_join() notification queue. When B dies, it wakes up A
using the wakeup_msg.

block on B

send join_msg

blocked on B
upcall_exit()

send Wakeup

Task A Task B

Вам также может понравиться