diff --git a/src/runtime2/poll/mod.rs b/src/runtime2/poll/mod.rs index 75cf8e9a90c00b6f9d785db8c8ce75221c69f0a3..2fc67d21192fb736ee7a12b58581c0f86bc42aaf 100644 --- a/src/runtime2/poll/mod.rs +++ b/src/runtime2/poll/mod.rs @@ -6,7 +6,7 @@ use std::sync::atomic::{AtomicU32, Ordering}; use std::collections::HashMap; use crate::runtime2::RtError; -use crate::runtime2::runtime::{CompHandle, RuntimeInner}; +use crate::runtime2::runtime::{CompHandle, RuntimeInner, LogLevel}; use crate::runtime2::store::queue_mpsc::*; @@ -139,11 +139,11 @@ pub struct PollingThread { poller: Arc, runtime: Arc, queue: QueueDynMpsc, - logging_enabled: bool, + log_level: LogLevel, } impl PollingThread { - pub(crate) fn new(runtime: Arc, logging_enabled: bool) -> Result<(PollingThreadHandle, PollingClientFactory), RtError> { + pub(crate) fn new(runtime: Arc, log_level: LogLevel) -> Result<(PollingThreadHandle, PollingClientFactory), RtError> { let poller = Poller::new() .map_err(|e| rt_error!("failed to create poller, because: {}", e))?; let poller = Arc::new(poller); @@ -154,9 +154,14 @@ impl PollingThread { poller: poller.clone(), runtime: runtime.clone(), queue, - logging_enabled, + log_level, }; - let thread_handle = thread::spawn(move || { thread_data.run() }); + let thread_handle = thread::Builder::new() + .name(String::from("poller")) + .spawn(move || { thread_data.run() }) + .map_err(|reason| + rt_error!("failed to start polling thread, because: {}", reason) + )?; let thread_handle = PollingThreadHandle{ queue: Some(queue_producers.producer()), @@ -172,7 +177,6 @@ impl PollingThread { } pub(crate) fn run(&mut self) { - use crate::runtime2::scheduler::SchedulerCtx; use crate::runtime2::communication::Message; const NUM_EVENTS: usize = 256; @@ -239,7 +243,7 @@ impl PollingThread { } fn log(&self, message: &str) { - if self.logging_enabled { + if self.log_level >= LogLevel::Info { println!("[polling] {}", message); } }