@@ -75,30 +75,6 @@ impl<T> Node<T> {
7575 }
7676}
7777
78- impl < T > Queue < T > {
79- #[ cfg( all( test, not( target_os = "emscripten" ) ) ) ]
80- /// Creates a new queue.
81- ///
82- /// This is unsafe as the type system doesn't enforce a single
83- /// consumer-producer relationship. It also allows the consumer to `pop`
84- /// items while there is a `peek` active due to all methods having a
85- /// non-mutable receiver.
86- ///
87- /// # Arguments
88- ///
89- /// * `bound` - This queue implementation is implemented with a linked
90- /// list, and this means that a push is always a malloc. In
91- /// order to amortize this cost, an internal cache of nodes is
92- /// maintained to prevent a malloc from always being
93- /// necessary. This bound is the limit on the size of the
94- /// cache (if desired). If the value is 0, then the cache has
95- /// no bound. Otherwise, the cache will never grow larger than
96- /// `bound` (although the queue itself could be much larger.
97- pub unsafe fn new ( bound : usize ) -> Queue < T > {
98- Self :: with_additions ( bound, ( ) , ( ) )
99- }
100- }
101-
10278impl < T , ProducerAddition , ConsumerAddition > Queue < T , ProducerAddition , ConsumerAddition > {
10379
10480 /// Creates a new queue. With given additional elements in the producer and
@@ -275,7 +251,7 @@ mod tests {
275251 #[ test]
276252 fn smoke ( ) {
277253 unsafe {
278- let queue = Queue :: new ( 0 ) ;
254+ let queue = Queue :: with_additions ( 0 , ( ) , ( ) ) ;
279255 queue. push ( 1 ) ;
280256 queue. push ( 2 ) ;
281257 assert_eq ! ( queue. pop( ) , Some ( 1 ) ) ;
@@ -292,7 +268,7 @@ mod tests {
292268 #[ test]
293269 fn peek ( ) {
294270 unsafe {
295- let queue = Queue :: new ( 0 ) ;
271+ let queue = Queue :: with_additions ( 0 , ( ) , ( ) ) ;
296272 queue. push ( vec ! [ 1 ] ) ;
297273
298274 // Ensure the borrowchecker works
@@ -315,7 +291,7 @@ mod tests {
315291 #[ test]
316292 fn drop_full ( ) {
317293 unsafe {
318- let q: Queue < Box < _ > > = Queue :: new ( 0 ) ;
294+ let q: Queue < Box < _ > > = Queue :: with_additions ( 0 , ( ) , ( ) ) ;
319295 q. push ( box 1 ) ;
320296 q. push ( box 2 ) ;
321297 }
@@ -324,7 +300,7 @@ mod tests {
324300 #[ test]
325301 fn smoke_bound ( ) {
326302 unsafe {
327- let q = Queue :: new ( 0 ) ;
303+ let q = Queue :: with_additions ( 0 , ( ) , ( ) ) ;
328304 q. push ( 1 ) ;
329305 q. push ( 2 ) ;
330306 assert_eq ! ( q. pop( ) , Some ( 1 ) ) ;
@@ -346,7 +322,7 @@ mod tests {
346322 }
347323
348324 unsafe fn stress_bound ( bound : usize ) {
349- let q = Arc :: new ( Queue :: new ( bound) ) ;
325+ let q = Arc :: new ( Queue :: with_additions ( bound, ( ) , ( ) ) ) ;
350326
351327 let ( tx, rx) = channel ( ) ;
352328 let q2 = q. clone ( ) ;
0 commit comments