generated from CDCgov/template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ff973ea
commit b2b5921
Showing
4 changed files
with
64 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Reports - Multi-Threaded Scenarios | ||
|
||
This example demonstrates report writing for several scenarios running in parallel. |
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,24 @@ | ||
use ixa::context::Context; | ||
use std::thread; | ||
|
||
fn main() { | ||
let scenarios = vec!["Illinois", "Wisconsin", "Arizona", "California"]; | ||
let mut handles = vec![]; | ||
|
||
for scenario in scenarios { | ||
let scenario = scenario.to_string(); | ||
let handle = thread::spawn(move || { | ||
// Replace this with the actual example code, similar to the simple | ||
// example in examples/reports/main.rs | ||
let mut context = Context::new(); | ||
println!("Scenario: {}", scenario); | ||
|
||
context.execute(); | ||
}); | ||
handles.push(handle); | ||
} | ||
|
||
for handle in handles { | ||
handle.join().unwrap(); | ||
} | ||
} |
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,4 @@ | ||
# Reports - Simple Example | ||
|
||
This example demonstrates creating two types of reports (incidence and death), | ||
and writing the reports from plans. |
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,33 @@ | ||
fn main() {} | ||
|
||
#[cfg(feature = "reports")] | ||
fn main() { | ||
struct Incidence { | ||
person_id: u32, | ||
t: f64, | ||
} | ||
struct Death { | ||
person_id: u32, | ||
t: f64, | ||
} | ||
|
||
let mut context = ixa::context::Context::new(); | ||
context.add_report::<Incidence>("incidence"); | ||
context.add_report::<Death>("death"); | ||
|
||
context.add_plan(1.0, |context| { | ||
context.send_report(Incidence { | ||
person_id: 1, | ||
t: context.get_current_time(), | ||
}); | ||
}); | ||
|
||
context.add_plan(2.0, |context| { | ||
context.send_report(Death { | ||
person_id: 1, | ||
t: context.get_current_time(), | ||
}); | ||
}); | ||
|
||
context.execute(); | ||
} |