File tree 1 file changed +16
-0
lines changed
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 78
78
//! within a Tokio runtime, however it is still not tied to one specific Tokio
79
79
//! runtime, and the sender may be moved from one Tokio runtime to another.
80
80
//!
81
+ //! # Allocation behavior
82
+ //!
83
+ //! <div class="warning">The implementation details described in this section may change in future
84
+ //! Tokio releases.</div>
85
+ //!
86
+ //! The mpsc channel stores elements in blocks. Blocks are organized in a linked list. Sending
87
+ //! pushes new elements onto the block at the front of the list, and receiving pops them off the
88
+ //! one at the back. A block can hold 32 messages on a 64-bit target and 16 messages on a 32-bit
89
+ //! target. This number is independent of channel and message size. Each block also stores 4
90
+ //! pointer-sized values for bookkeeping (so on a 64-bit machine, each message has 1 byte of
91
+ //! overhead).
92
+ //!
93
+ //! When all values in a block have been received, it becomes empty. It will then be freed, unless
94
+ //! the channel's first block (where newly-sent elements are being stored) has no next block. In
95
+ //! that case, the empty block is reused as the next block.
96
+ //!
81
97
//! [`Sender`]: crate::sync::mpsc::Sender
82
98
//! [`Receiver`]: crate::sync::mpsc::Receiver
83
99
//! [bounded-send]: crate::sync::mpsc::Sender::send()
You can’t perform that action at this time.
0 commit comments