@@ -103,34 +103,6 @@ impl<T> Producer<T> {
103103 true
104104 }
105105
106- /// Writes items into the queue or returns the iterator if there is not enough space.
107- ///
108- /// # Safety
109- /// - `items.len()` must exactly match the number of values yielded by `items`.
110- /// - Yielding fewer values will publish uninitialized memory.
111- /// - Yielding more values will drop unwritten items.
112- pub unsafe fn try_write_batch < I > ( & self , items : I ) -> Result < ( ) , I >
113- where
114- I : ExactSizeIterator < Item = T > ,
115- {
116- // SAFETY: if successful we write all items below
117- let mut guard = match unsafe { self . reserve_write_batch ( items. len ( ) ) } {
118- Some ( guard) => guard,
119- None => return Err ( items) ,
120- } ;
121-
122- let mut written = 0 ;
123- for ( index, item) in items. enumerate ( ) {
124- debug_assert ! ( index < guard. count) ;
125- // SAFETY: index is not out of bounds
126- unsafe { guard. write ( index, item) } ;
127- written = index + 1 ;
128- }
129- debug_assert_eq ! ( written, guard. count) ;
130-
131- Ok ( ( ) )
132- }
133-
134106 /// Reserves a slot for writing.
135107 /// The slot is committed when the guard is dropped.
136108 ///
@@ -249,19 +221,6 @@ impl<T> Consumer<T> {
249221 self . reserve_read ( ) . map ( ReadGuard :: read)
250222 }
251223
252- /// Attempts to read values from the queue.
253- /// Returns `None` if there are no values available.
254- pub fn try_read_batch (
255- & self ,
256- max_count : usize ,
257- ) -> Option < impl ExactSizeIterator < Item = T > + ' _ > {
258- self . reserve_read_batch ( max_count) . map ( |batch| {
259- ( 0 ..batch. count ) . map ( move |index|
260- // SAFETY: index is less than count
261- unsafe { batch. read ( index) } )
262- } )
263- }
264-
265224 /// Attempts to reserve a value from the queue, returning a guard.
266225 /// The slot is released back to producers when the guard is dropped.
267226 ///
@@ -959,21 +918,6 @@ mod tests {
959918 assert_eq ! ( consumer. try_read( ) , None ) ;
960919 }
961920
962- #[ test]
963- fn test_try_write_batch_unsafe_returns_iterator_when_no_capacity ( ) {
964- let small_size = minimum_file_size :: < Item > ( 4 ) ;
965- let ( _file, producer, _consumer) = create_test_queue :: < Item > ( small_size) ;
966-
967- for i in 0 ..4 {
968- assert_eq ! ( producer. try_write( i as Item ) , Ok ( ( ) ) ) ;
969- }
970-
971- let err = unsafe { producer. try_write_batch ( vec ! [ 100 , 101 ] . into_iter ( ) ) }
972- . expect_err ( "expected insufficient capacity" ) ;
973- let values: Vec < _ > = err. collect ( ) ;
974- assert_eq ! ( values, vec![ 100 , 101 ] ) ;
975- }
976-
977921 #[ test]
978922 fn test_minimum_file_size_rounds_up_capacity ( ) {
979923 let file = create_temp_shmem_file ( ) . unwrap ( ) ;
0 commit comments