aboutsummaryrefslogtreecommitdiffstats
path: root/third_party/webrender/webrender_api/src/channel.rs
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/webrender/webrender_api/src/channel.rs')
-rw-r--r--third_party/webrender/webrender_api/src/channel.rs63
1 files changed, 7 insertions, 56 deletions
diff --git a/third_party/webrender/webrender_api/src/channel.rs b/third_party/webrender/webrender_api/src/channel.rs
index 7d21c6e4339..2bc4a5f16b8 100644
--- a/third_party/webrender/webrender_api/src/channel.rs
+++ b/third_party/webrender/webrender_api/src/channel.rs
@@ -2,19 +2,12 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-use crate::{Epoch, PipelineId};
+use crate::api::{Epoch, PipelineId};
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::io::{self, Cursor, Error, ErrorKind, Read};
use std::mem;
-
-pub use crossbeam_channel as crossbeam;
-
-#[cfg(not(target_os = "windows"))]
-pub use crossbeam_channel::{Sender, Receiver};
-
-#[cfg(target_os = "windows")]
-pub use std::sync::mpsc::{Sender, Receiver};
+use std::sync::mpsc;
#[derive(Clone)]
pub struct Payload {
@@ -81,7 +74,7 @@ pub type PayloadSender = MsgSender<Payload>;
pub type PayloadReceiver = MsgReceiver<Payload>;
pub struct MsgReceiver<T> {
- rx: Receiver<T>,
+ rx: mpsc::Receiver<T>,
}
impl<T> MsgReceiver<T> {
@@ -89,14 +82,14 @@ impl<T> MsgReceiver<T> {
self.rx.recv().map_err(|e| io::Error::new(ErrorKind::Other, e.to_string()))
}
- pub fn to_crossbeam_receiver(self) -> Receiver<T> {
+ pub fn to_mpsc_receiver(self) -> mpsc::Receiver<T> {
self.rx
}
}
#[derive(Clone)]
pub struct MsgSender<T> {
- tx: Sender<T>,
+ tx: mpsc::Sender<T>,
}
impl<T> MsgSender<T> {
@@ -106,12 +99,12 @@ impl<T> MsgSender<T> {
}
pub fn payload_channel() -> Result<(PayloadSender, PayloadReceiver), Error> {
- let (tx, rx) = unbounded_channel();
+ let (tx, rx) = mpsc::channel();
Ok((PayloadSender { tx }, PayloadReceiver { rx }))
}
pub fn msg_channel<T>() -> Result<(MsgSender<T>, MsgReceiver<T>), Error> {
- let (tx, rx) = unbounded_channel();
+ let (tx, rx) = mpsc::channel();
Ok((MsgSender { tx }, MsgReceiver { rx }))
}
@@ -136,45 +129,3 @@ impl<'de, T> Deserialize<'de> for MsgSender<T> {
unreachable!();
}
}
-
-/// A create a channel intended for one-shot uses, for example the channels
-/// created to block on a synchronous query and then discarded,
-#[cfg(not(target_os = "windows"))]
-pub fn single_msg_channel<T>() -> (Sender<T>, Receiver<T>) {
- crossbeam_channel::bounded(1)
-}
-
-/// A fast MPMC message channel that can hold a fixed number of messages.
-///
-/// If the channel is full, the sender will block upon sending extra messages
-/// until the receiver has consumed some messages.
-/// The capacity parameter should be chosen either:
-/// - high enough to avoid blocking on the common cases,
-/// - or, on the contrary, using the blocking behavior as a means to prevent
-/// fast producers from building up work faster than it is consumed.
-#[cfg(not(target_os = "windows"))]
-pub fn fast_channel<T>(capacity: usize) -> (Sender<T>, Receiver<T>) {
- crossbeam_channel::bounded(capacity)
-}
-
-/// Creates an MPMC channel that is a bit slower than the fast_channel but doesn't
-/// have a limit on the number of messages held at a given time and therefore
-/// doesn't block when sending.
-#[cfg(not(target_os = "windows"))]
-pub use crossbeam_channel::unbounded as unbounded_channel;
-
-
-#[cfg(target_os = "windows")]
-pub fn fast_channel<T>(_cap: usize) -> (Sender<T>, Receiver<T>) {
- std::sync::mpsc::channel()
-}
-
-#[cfg(target_os = "windows")]
-pub fn unbounded_channel<T>() -> (Sender<T>, Receiver<T>) {
- std::sync::mpsc::channel()
-}
-
-#[cfg(target_os = "windows")]
-pub fn single_msg_channel<T>() -> (Sender<T>, Receiver<T>) {
- std::sync::mpsc::channel()
-}