pub struct TChan<T> { /* private fields */ }
Expand description

Ubounded queue using a linked list of TVars.

This implementation builds up a linked list of TVars with a read and a write pointer. The good thing is that the reads don’t cause retries in writes, unlike if it was just a single TVar with one data structure in it. It may also help that it’s more granular, and Transaction::downcast will not clone a full data structure.

Implementations

Create an empty TChan.

Both read and write TVars will be pointing at a common TVar containing an empty list.

   [TNil]
  / \
[*]  [*]
read write

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Returns the “default value” for a type. Read more

Pop the head of the queue, or retry until there is an element if it’s empty.

Moves the read TVar down the list to point at the next item.

 [TCons(x, [TCons(y, [TNil])])]
 |         |         |
[ ]       [*]       [*]
read0 ->  read1     write

Push to the end of the queue.

Replaces the contents of the current write TVar with a TCons and points the write TVar at a new TNil.

 [TCons(x, [TCons(y, [TNil])])]
 |         |         |
[*]       [ ]       [*]
read      write0 -> write1

Check if the queue is empty.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.