-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from garious/add-historian
Add historian demo
- Loading branch information
Showing
5 changed files
with
104 additions
and
20 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
extern crate silk; | ||
|
||
use silk::historian::Historian; | ||
use silk::log::{verify_slice, Entry, Event}; | ||
use std::{thread, time}; | ||
use std::sync::mpsc::SendError; | ||
|
||
fn create_log(hist: &Historian) -> Result<(), SendError<Event>> { | ||
hist.sender.send(Event::Tick)?; | ||
thread::sleep(time::Duration::new(0, 100_000)); | ||
hist.sender.send(Event::UserDataKey(0xdeadbeef))?; | ||
thread::sleep(time::Duration::new(0, 100_000)); | ||
hist.sender.send(Event::Tick)?; | ||
Ok(()) | ||
} | ||
|
||
fn main() { | ||
let seed = 0; | ||
let hist = Historian::new(seed); | ||
create_log(&hist).expect("send error"); | ||
drop(hist.sender); | ||
let entries: Vec<Entry> = hist.receiver.iter().collect(); | ||
for entry in &entries { | ||
println!("{:?}", entry); | ||
} | ||
assert!(verify_slice(&entries, seed)); | ||
} |
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
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