mirror of https://github.com/rwf2/Rocket.git
Update 'crossbeam' to 0.7 in 'managed_queue' example.
This commit is contained in:
parent
f4548f09af
commit
8afe5d3eaf
|
@ -5,5 +5,5 @@ workspace = "../.."
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
crossbeam = "0.5"
|
crossbeam = "0.7"
|
||||||
rocket = { path = "../../core/lib" }
|
rocket = { path = "../../core/lib" }
|
||||||
|
|
|
@ -6,9 +6,9 @@ extern crate crossbeam;
|
||||||
#[cfg(test)] mod tests;
|
#[cfg(test)] mod tests;
|
||||||
|
|
||||||
use rocket::State;
|
use rocket::State;
|
||||||
use crossbeam::queue::MsQueue;
|
use crossbeam::queue::SegQueue;
|
||||||
|
|
||||||
struct LogChannel(MsQueue<String>);
|
struct LogChannel(SegQueue<String>);
|
||||||
|
|
||||||
#[put("/push?<event>")]
|
#[put("/push?<event>")]
|
||||||
fn push(event: String, queue: State<LogChannel>) {
|
fn push(event: String, queue: State<LogChannel>) {
|
||||||
|
@ -16,14 +16,14 @@ fn push(event: String, queue: State<LogChannel>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/pop")]
|
#[get("/pop")]
|
||||||
fn pop(queue: State<LogChannel>) -> String {
|
fn pop(queue: State<LogChannel>) -> Option<String> {
|
||||||
queue.0.pop()
|
queue.0.pop().ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rocket() -> rocket::Rocket {
|
fn rocket() -> rocket::Rocket {
|
||||||
rocket::ignite()
|
rocket::ignite()
|
||||||
.mount("/", routes![push, pop])
|
.mount("/", routes![push, pop])
|
||||||
.manage(LogChannel(MsQueue::new()))
|
.manage(LogChannel(SegQueue::new()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
Loading…
Reference in New Issue