1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
/*!
# On Disk Ringbuffer
This is an extremely simple implementation of an on disk write-only log that
sort of pretends to be a ringbuffer! It uses memory-mapped pages to have interprocess,
lock-free, reads and writes. It's blazingly fast, but tends to hog disk-space for better
efficiency (less but bigger memory-mapped pages).
## Example
```rust
use disk_ringbuffer::ringbuf;
fn example() {
// takes directory to use as ringbuf storage and the total number of pages to store as input.
// note that each page takes 80Mb and setting the max_pages to zero implies an unbounded queue
let (mut tx, mut rx) = ringbuf::new("test-example", 2).unwrap();
// you can clone readers and writers to use in other threads!
let tx2 = tx.clone();
for i in 0..500_000 {
tx.push(i.to_string());
}
for i in 0..500_000 {
let m = rx.pop().unwrap().unwrap();
assert_eq!(m, i.to_string());
}
}
```
senders are also completely thread safe!
```rust
use disk_ringbuffer::ringbuf::new;
fn thread_example() {
let (mut tx, mut rx) = new("test-thread-example", 2).unwrap();
let mut tx2 = tx.clone();
let t = std::thread::spawn(move || {
for i in 0..500_000 {
tx.push(i.to_string()).unwrap();
}
});
tx2.push("asdf").unwrap();
t.join().unwrap();
}
```
*/
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
// stackoverflow says i shouldn't suppress this warning
#![allow(improper_ctypes)]
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
pub mod page;
pub mod ringbuf;