From b3e3b8becdbfc24f9b4da67acabd9dd9aa834901 Mon Sep 17 00:00:00 2001 From: Aaron Weiss Date: Tue, 23 Dec 2014 13:00:07 -0500 Subject: [PATCH] Updated examples with removal of deprecated code. --- examples/autoreconnect.rs | 5 +++-- examples/multithreaded.rs | 5 +++-- examples/tweeter.rs | 5 ++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/examples/autoreconnect.rs b/examples/autoreconnect.rs index 8da0ed1..9c4fc5f 100644 --- a/examples/autoreconnect.rs +++ b/examples/autoreconnect.rs @@ -3,6 +3,7 @@ extern crate irc; use std::default::Default; use std::sync::Arc; +use std::thread::Thread; use irc::data::{Command, Config}; use irc::server::{IrcServer, Server}; use irc::server::utils::Wrapper; @@ -17,7 +18,7 @@ fn main() { let irc_server = Arc::new(IrcServer::from_config(config).unwrap()); irc_server.conn().set_keepalive(Some(5)).unwrap(); // The wrapper provides us with methods like send_privmsg(...) and identify(...) - spawn(move || { + let _ = Thread::spawn(move || { let server = Wrapper::new(&*irc_server); server.identify().unwrap(); loop { @@ -41,5 +42,5 @@ fn main() { irc_server.reconnect().unwrap(); server.identify().unwrap(); } - }); + }).join(); } diff --git a/examples/multithreaded.rs b/examples/multithreaded.rs index 49d277e..4f88b69 100644 --- a/examples/multithreaded.rs +++ b/examples/multithreaded.rs @@ -3,6 +3,7 @@ extern crate irc; use std::default::Default; use std::sync::Arc; +use std::thread::Thread; use irc::data::config::Config; use irc::server::{IrcServer, Server}; use irc::server::utils::Wrapper; @@ -20,9 +21,9 @@ fn main() { server.identify().unwrap(); let server = irc_server.clone(); // We won't use a wrapper here because we don't need the added functionality. - spawn(move || { + let _ = Thread::spawn(move || { for msg in server.iter() { print!("{}", msg.unwrap().into_string()); } - }); + }).join(); // You might not want to join here for actual multi-threading. } diff --git a/examples/tweeter.rs b/examples/tweeter.rs index fa75220..b64bdd5 100644 --- a/examples/tweeter.rs +++ b/examples/tweeter.rs @@ -4,6 +4,7 @@ extern crate irc; use std::default::Default; use std::io::timer::sleep; use std::sync::Arc; +use std::thread::Thread; use std::time::duration::Duration; use irc::data::config::Config; use irc::server::{IrcServer, Server}; @@ -22,7 +23,9 @@ fn main() { let server = Wrapper::new(&*irc_server2); server.identify().unwrap(); // Let's set up a loop that just prints the messages. - spawn(move || { irc_server.iter().map(|m| print!("{}", m.unwrap().into_string())).count(); }); + Thread::spawn(move || { + irc_server.iter().map(|m| print!("{}", m.unwrap().into_string())).count(); + }).detach(); loop { server.send_privmsg("#vana", "TWEET TWEET").unwrap(); sleep(Duration::seconds(10))