summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/bot/music.rs64
1 files changed, 35 insertions, 29 deletions
diff --git a/src/bot/music.rs b/src/bot/music.rs
index dee1514..4de4d4b 100644
--- a/src/bot/music.rs
+++ b/src/bot/music.rs
@@ -369,40 +369,46 @@ impl MusicBot {
fn spawn_stdin_reader(tx: Arc<Mutex<UnboundedSender<MusicBotMessage>>>) {
debug!("Spawning stdin reader thread");
- thread::spawn(move || {
- let stdin = ::std::io::stdin();
- let lock = stdin.lock();
- for line in lock.lines() {
- let line = line.unwrap();
-
- let message = MusicBotMessage::TextMessage(Message {
- target: MessageTarget::Channel,
- invoker: Invoker {
- name: String::from("stdin"),
- id: ClientId(0),
- uid: None,
- },
- text: line,
- });
-
- let tx = tx.lock().unwrap();
- tx.send(message).unwrap();
- }
- });
+ thread::Builder::new()
+ .name(String::from("stdin reader"))
+ .spawn(move || {
+ let stdin = ::std::io::stdin();
+ let lock = stdin.lock();
+ for line in lock.lines() {
+ let line = line.unwrap();
+
+ let message = MusicBotMessage::TextMessage(Message {
+ target: MessageTarget::Channel,
+ invoker: Invoker {
+ name: String::from("stdin"),
+ id: ClientId(0),
+ uid: None,
+ },
+ text: line,
+ });
+
+ let tx = tx.lock().unwrap();
+ tx.send(message).unwrap();
+ }
+ })
+ .expect("Failed to spawn stdin reader thread");
}
fn spawn_gstreamer_thread(
player: Arc<AudioPlayer>,
tx: Arc<Mutex<UnboundedSender<MusicBotMessage>>>,
) {
- thread::spawn(move || loop {
- if player.poll() == PollResult::Quit {
- break;
- }
+ thread::Builder::new()
+ .name(String::from("gstreamer polling"))
+ .spawn(move || loop {
+ if player.poll() == PollResult::Quit {
+ break;
+ }
- tx.lock()
- .unwrap()
- .send(MusicBotMessage::StateChange(State::EndOfStream))
- .unwrap();
- });
+ tx.lock()
+ .unwrap()
+ .send(MusicBotMessage::StateChange(State::EndOfStream))
+ .unwrap();
+ })
+ .expect("Failed to spawn gstreamer thread");
}