@@ -3,8 +3,8 @@ use crate::sync::{AtomicUsize, Ordering};
33use std:: cell:: { Cell , UnsafeCell } ;
44use std:: ptr;
55
6- /// Single-Producer-Single-Consumer Ring Buffer
7- /// Cache line optimized
6+ /// Single-Producer-Single-Consumer Ring Buffer.
7+ /// (cache line optimized)
88#[ allow( dead_code) ]
99pub struct SPSCRingBuffer < T > {
1010 capacity : usize ,
4040 pub fn try_produce ( & self , value : T ) -> bool {
4141 let current_tail = self . tail . load ( Ordering :: Relaxed ) ;
4242
43- // Cache line optimisations
44- // Refresh cached_head only when the buffer *appears* full based on stale cache
43+ // Cache line optimizations
44+ // Обновлять cached_head только если буфер *кажется* заполненным на основе устаревшего кэша
4545 if self . next ( current_tail) == self . cached_head . get ( ) {
4646 self . cached_head . set ( self . head . load ( Ordering :: Acquire ) ) ;
4747 }
6565 pub fn try_consume ( & self ) -> Option < T > {
6666 let current_head = self . head . load ( Ordering :: Relaxed ) ;
6767
68- // Cache line optimisations
69- // Refresh cached_tail only when the buffer *appears* empty based on stale cache
68+ // Cache line optimizations
69+ // Обновлять cached_head только если буфер *кажется* заполненным на основе устаревшего кэша
7070 if current_head == self . cached_tail . get ( ) {
7171 self . cached_tail . set ( self . tail . load ( Ordering :: Acquire ) ) ;
7272 }
0 commit comments