Skip to content

Commit 73e0e66

Browse files
committed
feat: update readme
1 parent b6b1114 commit 73e0e66

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "fq"
3-
version = "0.0.1"
3+
version = "0.0.2"
44
authors = ["QEDK <[email protected]>"]
55
edition = "2024"
66
description = "A fast and simple ring-buffer-based single-producer, single-consumer queue with no dependencies. You can use this to write Rust programs with low-latency message passing."

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ A fast and simple ring-buffer-based single-producer, single-consumer queue with
66
77
## Installation
88
Add this to your `Cargo.toml`:
9-
```toml
9+
```TOML
1010
[dependencies]
1111
fq = "0.0.2"
1212
```
@@ -32,3 +32,16 @@ let receiver = thread::spawn(move || {
3232
sender.join().expect("The sender thread has panicked");
3333
receiver.join().expect("The receiver thread has panicked");
3434
```
35+
36+
## License
37+
38+
Licensed under either of:
39+
* MIT license ([LICENSE-MIT](LICENSE-MIT))
40+
* Lesser General Public license v3.0 or later ([LICENSE-LGPL](LICENSE-LGPL))
41+
at your option.
42+
43+
### Contribution
44+
45+
Unless you explicitly state otherwise, any contribution intentionally submitted
46+
for inclusion in the work by you, as defined in the LGPL-3.0 license, shall be dual licensed as above, without any
47+
additional terms or conditions.

src/lib.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ A fast and simple ring-buffer-based single-producer, single-consumer queue with
33
44
## Installation
55
Add this to your `Cargo.toml`:
6-
```toml
6+
```TOML
77
[dependencies]
88
fq = "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.
155156
pub 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

267268
unsafe impl<T: Send> Send for Consumer<T> {}
268269

270+
/// A consumer for the `FastQueue`. This is used to pop values from the queue.
269271
impl<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

Comments
 (0)