@@ -3,7 +3,7 @@ A fast and simple ring-buffer-based single-producer, single-consumer queue with
33
44## Installation
55Add this to your `Cargo.toml`:
6- ```toml
6+ ```TOML
77[dependencies]
88fq = "0.0.2"
99```
@@ -97,7 +97,7 @@ impl<T> FastQueue<T> {
9797 let capacity = capacity. next_power_of_two ( ) . max ( 2 ) ;
9898 let mask = capacity - 1 ;
9999
100- let layout = Layout :: array :: < MaybeUninit < T > > ( capacity) . expect ( "Layout calculation failed " ) ;
100+ let layout = Layout :: array :: < MaybeUninit < T > > ( capacity) . expect ( "layout " ) ;
101101 let buffer = unsafe { alloc ( layout) as * mut MaybeUninit < T > } ;
102102
103103 if buffer. is_null ( ) {
@@ -146,12 +146,13 @@ impl<T> Drop for FastQueue<T> {
146146
147147 unsafe {
148148 let layout = Layout :: array :: < MaybeUninit < T > > ( self . capacity . 0 )
149- . expect ( "Layout calculation failed " ) ;
149+ . expect ( "layout " ) ;
150150 dealloc ( self . buffer . 0 as * mut u8 , layout) ;
151151 }
152152 }
153153}
154154
155+ /// A producer for the `FastQueue`. This is used to push values into the queue.
155156pub struct Producer < T > {
156157 queue : Arc < FastQueue < T > > ,
157158}
@@ -164,7 +165,7 @@ impl<T> Producer<T> {
164165 /// # Example
165166 /// ```
166167 /// use fq::FastQueue;
167- /// let (mut producer, mut consumer) = FastQueue::new(1024 );
168+ /// let (mut producer, mut consumer) = FastQueue::new(2 );
168169 /// producer.push(42).unwrap();
169170 /// assert_eq!(consumer.pop(), Some(42));
170171 /// ```
@@ -266,13 +267,14 @@ pub struct Consumer<T> {
266267
267268unsafe impl < T : Send > Send for Consumer < T > { }
268269
270+ /// A consumer for the `FastQueue`. This is used to pop values from the queue.
269271impl < T > Consumer < T > {
270272 /// Pops a value from the queue. Returns `Some(T)` on success or `None` if the queue is empty.
271273 ///
272274 /// # Example
273275 /// ```
274276 /// use fq::FastQueue;
275- /// let (mut producer, mut consumer) = FastQueue::new(1024 );
277+ /// let (mut producer, mut consumer) = FastQueue::new(2 );
276278 /// producer.push(42).unwrap();
277279 /// assert_eq!(consumer.pop(), Some(42));
278280 /// ```
0 commit comments