forked from jgrimes/fruently
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
2 changed files
with
31 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
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,29 @@ | ||
extern crate fruently; | ||
#[cfg(feature = "crossbeam")] | ||
extern crate crossbeam; | ||
|
||
#[cfg(feature = "crossbeam")] | ||
fn crossbeam_thread() { | ||
use fruently::fluent::Fluent; | ||
use std::collections::HashMap; | ||
use fruently::forwardable::JsonForwardable; | ||
|
||
let fruently = Fluent::new("127.0.0.1:24224", "test"); | ||
let mut obj: HashMap<String, String> = HashMap::new(); | ||
obj.insert("threaded".to_string(), "fruently".to_string()); | ||
let _threads: Vec<_> = (0..10) | ||
.map(|_| { | ||
let obj = obj.clone(); | ||
let fruently = fruently.clone(); | ||
crossbeam::scope(|scope| { | ||
scope.spawn(|| { let _ = fruently.post(&obj); }) | ||
}); | ||
}) | ||
.collect(); | ||
} | ||
#[cfg(not(feature = "crossbeam"))] | ||
fn crossbeam_thread() {} | ||
|
||
fn main() { | ||
crossbeam_thread(); | ||
} |