Tracing shutdown and changed order of IoManager shutdown process

This commit is contained in:
Tomasz Drwięga 2016-04-06 23:45:19 +02:00
parent fd03f58eae
commit d4f0902968
3 changed files with 7 additions and 1 deletions

View File

@ -431,12 +431,14 @@ impl MayPanic for BlockQueue {
impl Drop for BlockQueue {
fn drop(&mut self) {
trace!(target: "shutdown", "[BlockQueue] Closing...");
self.clear();
self.deleting.store(true, AtomicOrdering::Release);
self.more_to_verify.notify_all();
for t in self.verifiers.drain(..) {
t.join().unwrap();
}
trace!(target: "shutdown", "[BlockQueue] Closed.");
}
}

View File

@ -231,8 +231,8 @@ impl<Message> Handler for IoManager<Message> where Message: Send + Clone + Sync
fn notify(&mut self, event_loop: &mut EventLoop<Self>, msg: Self::Message) {
match msg {
IoMessage::Shutdown => {
self.workers.clear();
event_loop.shutdown();
self.workers.clear();
},
IoMessage::AddHandler { handler } => {
let handler_id = {
@ -376,8 +376,10 @@ impl<Message> IoService<Message> where Message: Send + Sync + Clone + 'static {
impl<Message> Drop for IoService<Message> where Message: Send + Sync + Clone {
fn drop(&mut self) {
trace!(target: "shutdown", "[IoService] Closing...");
self.host_channel.send(IoMessage::Shutdown).unwrap();
self.thread.take().unwrap().join().ok();
trace!(target: "shutdown", "[IoService] Closed.");
}
}

View File

@ -120,10 +120,12 @@ impl Worker {
impl Drop for Worker {
fn drop(&mut self) {
trace!(target: "shutdown", "[IoWorker] Closing...");
let _ = self.wait_mutex.lock();
self.deleting.store(true, AtomicOrdering::Release);
self.wait.notify_all();
let thread = mem::replace(&mut self.thread, None).unwrap();
thread.join().ok();
trace!(target: "shutdown", "[IoWorker] Closed");
}
}