-
-
Save egonelbre/eadeed2ff4a07226670b484e9a2a2b5b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate ringtail; | |
use ringtail::buffers::*; | |
fn main() { | |
let mut buffer = ringtail::buffers::atomic::bounded::<i64>(2); | |
println!("{}", buffer.1.push(&[100])); | |
println!("{}", buffer.1.push(&[200])); | |
println!("{}", buffer.1.push(&[300])); | |
println!("{}", buffer.1.push(&[400])); | |
let mut dst = [0; 1]; | |
let x = buffer.0.pull(&mut dst); | |
println!("got: {} -> {}", x, dst[0]); | |
let mut dst = [0; 1]; | |
let x = buffer.0.pull(&mut dst); | |
println!("got: {} -> {}", x, dst[0]); | |
let mut dst = [0; 1]; | |
let x = buffer.0.pull(&mut dst); | |
println!("got: {} -> {}", x, dst[0]); | |
let mut dst = [0; 1]; | |
let x = buffer.0.pull(&mut dst); | |
println!("got: {} -> {}", x, dst[0]); | |
let mut dst = [0; 1]; | |
let x = buffer.0.pull(&mut dst); | |
println!("got: {} -> {}", x, dst[0]); | |
} | |
// Output: | |
// 1 | |
// 1 | |
// 1 | |
// 1 | |
// got: 1 -> 300 | |
// got: 1 -> 400 | |
// got: 1 -> 300 | |
// got: 1 -> 400 | |
// got: 0 -> 300 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment