diff --git a/src/runtime2/runtime.rs b/src/runtime2/runtime.rs index fb8df772666e3c76b344d84977f4ceeeef71cf2e..2c68998ea2f78728e3938f6aee435a313405c14c 100644 --- a/src/runtime2/runtime.rs +++ b/src/runtime2/runtime.rs @@ -4,7 +4,7 @@ use std::thread; use std::collections::VecDeque; use crate::protocol::*; -use crate::runtime2::poll::{PollingThreadBuilder, PollingThreadDestroyer}; +use crate::runtime2::poll::{PollingThread, PollingThreadHandle}; use crate::runtime2::RtError; use super::communication::Message; @@ -162,8 +162,7 @@ impl Drop for CompHandle { pub struct Runtime { pub(crate) inner: Arc, scheduler_threads: Vec>, - polling_destroyer: PollingThreadDestroyer, - polling_thread: Option>, + polling_handle: PollingThreadHandle, } impl Runtime { @@ -179,8 +178,8 @@ impl Runtime { work_condvar: Condvar::new(), active_elements: AtomicU32::new(1), }); - let polling_builder = rt_error_try!( - PollingThreadBuilder::new(runtime_inner.clone(), debug_logging), + let (polling_handle, polling_clients) = rt_error_try!( + PollingThread::new(runtime_inner.clone(), debug_logging), "failed to build polling thread" ); @@ -188,7 +187,7 @@ impl Runtime { for thread_index in 0..num_threads { let mut scheduler = Scheduler::new( - runtime_inner.clone(), polling_builder.client(), + runtime_inner.clone(), polling_clients.client(), thread_index, debug_logging ); let thread_handle = thread::spawn(move || { @@ -198,16 +197,10 @@ impl Runtime { scheduler_threads.push(thread_handle); } - let (mut poller, polling_destroyer) = polling_builder.into_thread(); - let polling_thread = thread::spawn(move || { - poller.run(); - }); - return Ok(Runtime{ inner: runtime_inner, scheduler_threads, - polling_destroyer, - polling_thread: Some(polling_thread), + polling_handle, }); } @@ -234,8 +227,7 @@ impl Drop for Runtime { handle.join().expect("join scheduler thread"); } - self.polling_destroyer.initiate_destruction(); - self.polling_thread.take().unwrap().join().expect("join polling thread"); + self.polling_handle.shutdown().expect("shutdown polling thread"); } }