Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce scope of tokio dependencies #10

Merged
merged 6 commits into from
Dec 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ language: rust
sudo: required

rust:
- 1.26.0
- 1.31.0
- stable
- beta
- nightly
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## Unreleased - ReleaseDate
### Changed
- Minimum compiler version has increased to 1.31.0
([#10](https://github.com/asomers/futures-locks/pull/10))
- `futures-locks` only depends on tokio crates `tokio-current-thread` and
`tokio-executor` when built with the `tokio` feature.
([#10](https://github.com/asomers/futures-locks/pull/10))

## [0.3.0] - 2018-06-28
### Added
- Added `Mutex::with_local`, `RwLock::with_read_local`, and
Expand Down
9 changes: 7 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@ autotests = false

[features]
default = ["tokio"]
tokio = ["tokio-current-thread", "tokio-executor"]

[dependencies]
futures = "0.1.20"
tokio = { version = "0.1.7", optional = true }
tokio-current-thread = { version = "0.1.4", optional = true }
tokio-executor = { version = "0.1.5", optional = true }

[dev-dependencies]
tokio = "0.1.4"
# features, dependencies, dev-dependencies, and build-dependencies all share
# the same namespace. To avoid a clash with the `tokio` feature, rename the
# `tokio` dev-dependency. See https://github.com/rust-lang/cargo/issues/4866.
tokio_ = { version = "0.1.4", package = "tokio" }

[[test]]
name = "functional"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ standard library. But instead of blocking until ready, they return Futures
which will become ready when the lock is acquired. See the doc comments for
individual examples.

`futures-locks` requires Rust 1.26.0 or higher.
`futures-locks` requires Rust 1.31.0 or higher.

# License

Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
//! [`Tokio`]: https:/tokio.rs

extern crate futures;
#[cfg(feature = "tokio")] extern crate tokio;
#[cfg(feature = "tokio")] extern crate tokio_current_thread;
#[cfg(feature = "tokio")] extern crate tokio_executor;

mod mutex;
mod rwlock;
Expand Down
11 changes: 5 additions & 6 deletions src/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ use std::collections::VecDeque;
use std::ops::{Deref, DerefMut};
use std::sync;
use super::FutState;
#[cfg(feature = "tokio")] use tokio;
#[cfg(feature = "tokio")] use tokio::executor::{Executor, SpawnError};
#[cfg(feature = "tokio")] use tokio::executor::current_thread;
#[cfg(feature = "tokio")] use tokio_executor::{self, Executor, SpawnError};
#[cfg(feature = "tokio")] use tokio_current_thread as current_thread;

/// An RAII mutex guard, much like `std::sync::MutexGuard`. The wrapped data
/// can be accessed via its `Deref` and `DerefMut` implementations.
Expand Down Expand Up @@ -315,7 +314,7 @@ impl<T: 'static + ?Sized> Mutex<T> {
/// ```
/// # extern crate futures;
/// # extern crate futures_locks;
/// # extern crate tokio;
/// # extern crate tokio_ as tokio;
/// # use futures_locks::*;
/// # use futures::{Future, IntoFuture, lazy};
/// # use tokio::runtime::current_thread::Runtime;
Expand Down Expand Up @@ -343,7 +342,7 @@ impl<T: 'static + ?Sized> Mutex<T> {
T: Send
{
let (tx, rx) = oneshot::channel::<Result<R, E>>();
tokio::executor::DefaultExecutor::current().spawn(Box::new(self.lock()
tokio_executor::DefaultExecutor::current().spawn(Box::new(self.lock()
.and_then(move |data| {
f(data).into_future()
.then(move |result| {
Expand All @@ -369,7 +368,7 @@ impl<T: 'static + ?Sized> Mutex<T> {
/// ```
/// # extern crate futures;
/// # extern crate futures_locks;
/// # extern crate tokio;
/// # extern crate tokio_ as tokio;
/// # use futures_locks::*;
/// # use futures::{Future, IntoFuture, lazy};
/// # use std::rc::Rc;
Expand Down
17 changes: 8 additions & 9 deletions src/rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ use std::collections::VecDeque;
use std::ops::{Deref, DerefMut};
use std::sync;
use super::FutState;
#[cfg(feature = "tokio")] use tokio;
#[cfg(feature = "tokio")] use tokio::executor::{Executor, SpawnError};
#[cfg(feature = "tokio")] use tokio::executor::current_thread;
#[cfg(feature = "tokio")] use tokio_executor::{self, Executor, SpawnError};
#[cfg(feature = "tokio")] use tokio_current_thread as current_thread;

/// An RAII guard, much like `std::sync::RwLockReadGuard`. The wrapped data can
/// be accessed via its `Deref` implementation.
Expand Down Expand Up @@ -512,7 +511,7 @@ impl<T: 'static + ?Sized> RwLock<T> {
/// ```
/// # extern crate futures;
/// # extern crate futures_locks;
/// # extern crate tokio;
/// # extern crate tokio_ as tokio;
/// # use futures_locks::*;
/// # use futures::{Future, IntoFuture, lazy};
/// # use tokio::runtime::current_thread::Runtime;
Expand All @@ -538,7 +537,7 @@ impl<T: 'static + ?Sized> RwLock<T> {
T: Send
{
let (tx, rx) = oneshot::channel::<Result<R, E>>();
tokio::executor::DefaultExecutor::current().spawn(Box::new(self.read()
tokio_executor::DefaultExecutor::current().spawn(Box::new(self.read()
.and_then(move |data| {
f(data).into_future()
.then(move |result| {
Expand All @@ -565,7 +564,7 @@ impl<T: 'static + ?Sized> RwLock<T> {
/// ```
/// # extern crate futures;
/// # extern crate futures_locks;
/// # extern crate tokio;
/// # extern crate tokio_ as tokio;
/// # use futures_locks::*;
/// # use futures::{Future, IntoFuture, lazy};
/// # use std::rc::Rc;
Expand Down Expand Up @@ -627,7 +626,7 @@ impl<T: 'static + ?Sized> RwLock<T> {
/// ```
/// # extern crate futures;
/// # extern crate futures_locks;
/// # extern crate tokio;
/// # extern crate tokio_ as tokio;
/// # use futures_locks::*;
/// # use futures::{Future, IntoFuture, lazy};
/// # use tokio::runtime::current_thread::Runtime;
Expand Down Expand Up @@ -655,7 +654,7 @@ impl<T: 'static + ?Sized> RwLock<T> {
T: Send
{
let (tx, rx) = oneshot::channel::<Result<R, E>>();
tokio::executor::DefaultExecutor::current().spawn(Box::new(self.write()
tokio_executor::DefaultExecutor::current().spawn(Box::new(self.write()
.and_then(move |data| {
f(data).into_future()
.then(move |result| {
Expand All @@ -682,7 +681,7 @@ impl<T: 'static + ?Sized> RwLock<T> {
/// ```
/// # extern crate futures;
/// # extern crate futures_locks;
/// # extern crate tokio;
/// # extern crate tokio_ as tokio;
/// # use futures_locks::*;
/// # use futures::{Future, IntoFuture, lazy};
/// # use std::rc::Rc;
Expand Down
2 changes: 1 addition & 1 deletion tests/test.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//vim: tw=80

extern crate futures;
extern crate tokio;
extern crate tokio_ as tokio;
extern crate futures_locks;

mod mutex;
Expand Down