threadshare: Move to tokio_threadpool and tokio_current_thread crates

This commit is contained in:
Sebastian Dröge 2018-06-24 15:06:11 +03:00
parent 23b25b210b
commit 987f78de42
3 changed files with 7 additions and 5 deletions

View file

@ -16,6 +16,7 @@ tokio-reactor = { git = "https://github.com/tokio-rs/tokio" }
tokio-executor = { git = "https://github.com/tokio-rs/tokio" } tokio-executor = { git = "https://github.com/tokio-rs/tokio" }
tokio-timer = { git = "https://github.com/tokio-rs/tokio" } tokio-timer = { git = "https://github.com/tokio-rs/tokio" }
tokio-threadpool = { git = "https://github.com/tokio-rs/tokio" } tokio-threadpool = { git = "https://github.com/tokio-rs/tokio" }
tokio-current-thread = { git = "https://github.com/tokio-rs/tokio" }
futures = "0.1" futures = "0.1"
lazy_static = "1.0" lazy_static = "1.0"
either = "1.0" either = "1.0"

View file

@ -26,7 +26,7 @@ use futures::future;
use futures::stream::futures_unordered::FuturesUnordered; use futures::stream::futures_unordered::FuturesUnordered;
use futures::sync::oneshot; use futures::sync::oneshot;
use futures::{Future, Stream}; use futures::{Future, Stream};
use tokio::executor::thread_pool; use tokio_threadpool;
use tokio::reactor; use tokio::reactor;
use tokio_timer::timer; use tokio_timer::timer;
@ -124,13 +124,13 @@ impl IOContextRunner {
gst_debug!(CONTEXT_CAT, "Started reactor thread '{}'", self.name); gst_debug!(CONTEXT_CAT, "Started reactor thread '{}'", self.name);
if let Some(ref pending_futures) = self.pending_futures { if let Some(ref pending_futures) = self.pending_futures {
use tokio::executor::current_thread; use tokio_current_thread;
let handle = reactor.handle(); let handle = reactor.handle();
let mut enter = ::tokio_executor::enter().unwrap(); let mut enter = ::tokio_executor::enter().unwrap();
let timer = timer::Timer::new(reactor); let timer = timer::Timer::new(reactor);
let timer_handle = timer.handle(); let timer_handle = timer.handle();
let mut current_thread = current_thread::CurrentThread::new_with_park(timer); let mut current_thread = tokio_current_thread::CurrentThread::new_with_park(timer);
::tokio_reactor::with_default(&handle, &mut enter, |mut enter| { ::tokio_reactor::with_default(&handle, &mut enter, |mut enter| {
::tokio_timer::with_default(&timer_handle, &mut enter, |enter| loop { ::tokio_timer::with_default(&timer_handle, &mut enter, |enter| loop {
@ -245,7 +245,7 @@ pub struct IOContext(Arc<IOContextInner>);
struct IOContextInner { struct IOContextInner {
name: String, name: String,
pool: Either<thread_pool::ThreadPool, IOContextExecutor>, pool: Either<tokio_threadpool::ThreadPool, IOContextExecutor>,
handle: reactor::Handle, handle: reactor::Handle,
// Only used for dropping // Only used for dropping
_shutdown: IOContextShutdown, _shutdown: IOContextShutdown,
@ -284,7 +284,7 @@ impl IOContext {
let shutdown = IOContextRunner::start(name, wait, reactor); let shutdown = IOContextRunner::start(name, wait, reactor);
// FIXME: The executor threads are not throttled at all, only the reactor // FIXME: The executor threads are not throttled at all, only the reactor
let mut pool_builder = thread_pool::Builder::new(); let mut pool_builder = tokio_threadpool::Builder::new();
pool_builder pool_builder
.around_worker(move |w, enter| { .around_worker(move |w, enter| {
let timer_handle = t1.lock().unwrap().get(w.id()).unwrap().clone(); let timer_handle = t1.lock().unwrap().get(w.id()).unwrap().clone();

View file

@ -32,6 +32,7 @@ extern crate tokio;
extern crate tokio_executor; extern crate tokio_executor;
extern crate tokio_reactor; extern crate tokio_reactor;
extern crate tokio_threadpool; extern crate tokio_threadpool;
extern crate tokio_current_thread;
extern crate tokio_timer; extern crate tokio_timer;
extern crate either; extern crate either;