@@ -166,12 +166,21 @@ impl<T> Producer<T> {
166166
167167 #[ cfg( any(
168168 target_arch = "x86" ,
169- all( target_arch = "x86_64" , target_feature = "sse" )
169+ all(
170+ target_arch = "x86_64" ,
171+ any( target_feature = "prfchw" , target_feature = "sse" )
172+ )
170173 ) ) ]
171174 unsafe {
172175 let next_index = next_head & self . queue . 0 . mask . 0 ;
173176 let next_slot = self . queue . 0 . buffer . 0 . add ( next_index) ;
174- prefetch_write ( next_slot as * const u8 ) ;
177+ prefetch_read ( next_slot as * const u8 ) ;
178+ // check if prfchw is available
179+ if is_x86_feature_detected ! ( "sse" ) {
180+ prefetch_read ( next_slot as * const u8 ) ;
181+ } else {
182+ prefetch_write ( next_slot as * const u8 ) ;
183+ }
175184 }
176185
177186 let cached_tail = unsafe { * self . cached_tail . 0 . get ( ) } ;
@@ -332,7 +341,7 @@ impl<T> Consumer<T> {
332341 #[ inline( always) ]
333342 pub fn peek ( & self ) -> Option < & T > {
334343 let tail = unsafe { * self . tail . 0 . get ( ) } ;
335- let head = self . queue . 0 . head . 0 . load ( Ordering :: Relaxed ) ;
344+ let head = self . queue . 0 . head . 0 . load ( Ordering :: Acquire ) ;
336345
337346 if tail == head {
338347 return None ;
@@ -397,7 +406,7 @@ fn prefetch_read(p: *const u8) {
397406
398407#[ cfg( any(
399408 target_arch = "x86" ,
400- all( target_arch = "x86_64" , target_feature = "sse " )
409+ all( target_arch = "x86_64" , target_feature = "prfchw " )
401410) ) ]
402411#[ inline( always) ]
403412fn prefetch_write ( p : * const u8 ) {
0 commit comments