@@ -99,8 +99,8 @@ impl<T, ProducerAddition, ConsumerAddition> Queue<T, ProducerAddition, ConsumerA
99
99
) -> Self {
100
100
let n1 = Node :: new ( ) ;
101
101
let n2 = Node :: new ( ) ;
102
- // SAFETY: At this point we know the pointer is not NUL since it was
103
- // build just above.
102
+ // SAFETY: At this point we know the pointer is valid: it was built
103
+ // just above.
104
104
unsafe { ( * n1) . next . store ( n2, Ordering :: Relaxed ) }
105
105
Queue {
106
106
consumer : CacheAligned :: new ( Consumer {
@@ -135,13 +135,10 @@ impl<T, ProducerAddition, ConsumerAddition> Queue<T, ProducerAddition, ConsumerA
135
135
}
136
136
137
137
unsafe fn alloc ( & self ) -> * mut Node < T > {
138
- // First try to see if we can consume the 'first' node for our uses.
139
- // SAFEY: Since `self` is a valid reference, accessing its inner values
140
- // can be considered safe (without checking for NUL pointers).
141
- //
142
- // Dereferencing of `ret` are safe too because the pointer comes from
143
- // `self` once again.
138
+ // SAFEY: ??? Explain why the pointers are safe to dereference and why
139
+ // returning a mutable pointer is ok. ???
144
140
unsafe {
141
+ // First try to see if we can consume the 'first' node for our uses.
145
142
if * self . producer . first . get ( ) != * self . producer . tail_copy . get ( ) {
146
143
let ret = * self . producer . first . get ( ) ;
147
144
* self . producer . 0 . first . get ( ) = ( * ret) . next . load ( Ordering :: Relaxed ) ;
@@ -322,7 +319,7 @@ mod tests {
322
319
}
323
320
324
321
unsafe fn stress_bound ( bound : usize ) {
325
- let q = Arc :: new ( Queue :: with_additions ( bound, ( ) , ( ) ) ) ;
322
+ let q = Arc :: new ( unsafe { Queue :: with_additions ( bound, ( ) , ( ) ) } ) ;
326
323
327
324
let ( tx, rx) = channel ( ) ;
328
325
let q2 = q. clone ( ) ;
0 commit comments