aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMs2ger <ms2ger@gmail.com>2016-02-01 17:40:58 +0100
committerMs2ger <ms2ger@gmail.com>2016-02-01 17:40:58 +0100
commit2fd53c266e3a550a10fffc163caf98dee779e19d (patch)
tree03fe98ef4d942a5e0b5c94e6b572cce207d5d99e
parent220ead14b16c8965335a6d54e037f2e30fc634ea (diff)
downloadservo-2fd53c266e3a550a10fffc163caf98dee779e19d.tar.gz
servo-2fd53c266e3a550a10fffc163caf98dee779e19d.zip
Use the select macro on the paint thread.
-rw-r--r--components/gfx/paint_thread.rs23
1 files changed, 8 insertions, 15 deletions
diff --git a/components/gfx/paint_thread.rs b/components/gfx/paint_thread.rs
index 212ca28eec1..fdb85aff339 100644
--- a/components/gfx/paint_thread.rs
+++ b/components/gfx/paint_thread.rs
@@ -30,7 +30,7 @@ use std::borrow::ToOwned;
use std::collections::HashMap;
use std::mem as std_mem;
use std::sync::Arc;
-use std::sync::mpsc::{Receiver, Select, Sender, channel};
+use std::sync::mpsc::{Receiver, Sender, channel};
use url::Url;
use util::geometry::{ExpandToPixelBoundaries};
use util::opts;
@@ -301,20 +301,13 @@ impl<C> PaintThread<C> where C: PaintListener + Send + 'static {
loop {
let message = {
- let select = Select::new();
- let mut layout_to_paint_handle = select.handle(&self.layout_to_paint_port);
- let mut chrome_to_paint_handle = select.handle(&self.chrome_to_paint_port);
- unsafe {
- layout_to_paint_handle.add();
- chrome_to_paint_handle.add();
- }
- let result = select.wait();
- if result == layout_to_paint_handle.id() {
- Msg::FromLayout(self.layout_to_paint_port.recv().unwrap())
- } else if result == chrome_to_paint_handle.id() {
- Msg::FromChrome(self.chrome_to_paint_port.recv().unwrap())
- } else {
- panic!("unexpected select result")
+ let layout_to_paint = &self.layout_to_paint_port;
+ let chrome_to_paint = &self.chrome_to_paint_port;
+ select! {
+ msg = layout_to_paint.recv() =>
+ Msg::FromLayout(msg.unwrap()),
+ msg = chrome_to_paint.recv() =>
+ Msg::FromChrome(msg.unwrap())
}
};