@@ -75,30 +75,6 @@ impl<T> Node<T> {
75
75
}
76
76
}
77
77
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
-
102
78
impl < T , ProducerAddition , ConsumerAddition > Queue < T , ProducerAddition , ConsumerAddition > {
103
79
104
80
/// Creates a new queue. With given additional elements in the producer and
@@ -275,7 +251,7 @@ mod tests {
275
251
#[ test]
276
252
fn smoke ( ) {
277
253
unsafe {
278
- let queue = Queue :: new ( 0 ) ;
254
+ let queue = Queue :: with_additions ( 0 , ( ) , ( ) ) ;
279
255
queue. push ( 1 ) ;
280
256
queue. push ( 2 ) ;
281
257
assert_eq ! ( queue. pop( ) , Some ( 1 ) ) ;
@@ -292,7 +268,7 @@ mod tests {
292
268
#[ test]
293
269
fn peek ( ) {
294
270
unsafe {
295
- let queue = Queue :: new ( 0 ) ;
271
+ let queue = Queue :: with_additions ( 0 , ( ) , ( ) ) ;
296
272
queue. push ( vec ! [ 1 ] ) ;
297
273
298
274
// Ensure the borrowchecker works
@@ -315,7 +291,7 @@ mod tests {
315
291
#[ test]
316
292
fn drop_full ( ) {
317
293
unsafe {
318
- let q: Queue < Box < _ > > = Queue :: new ( 0 ) ;
294
+ let q: Queue < Box < _ > > = Queue :: with_additions ( 0 , ( ) , ( ) ) ;
319
295
q. push ( box 1 ) ;
320
296
q. push ( box 2 ) ;
321
297
}
@@ -324,7 +300,7 @@ mod tests {
324
300
#[ test]
325
301
fn smoke_bound ( ) {
326
302
unsafe {
327
- let q = Queue :: new ( 0 ) ;
303
+ let q = Queue :: with_additions ( 0 , ( ) , ( ) ) ;
328
304
q. push ( 1 ) ;
329
305
q. push ( 2 ) ;
330
306
assert_eq ! ( q. pop( ) , Some ( 1 ) ) ;
@@ -346,7 +322,7 @@ mod tests {
346
322
}
347
323
348
324
unsafe fn stress_bound ( bound : usize ) {
349
- let q = Arc :: new ( Queue :: new ( bound) ) ;
325
+ let q = Arc :: new ( Queue :: with_additions ( bound, ( ) , ( ) ) ) ;
350
326
351
327
let ( tx, rx) = channel ( ) ;
352
328
let q2 = q. clone ( ) ;
0 commit comments