Skip to content

Commit

Permalink
Merge branch 'master' into fix_doc_test
Browse files Browse the repository at this point in the history
  • Loading branch information
k-nasa committed May 20, 2020
2 parents b88138b + 9e6a76a commit d30603a
Show file tree
Hide file tree
Showing 64 changed files with 1,595 additions and 1,576 deletions.
77 changes: 59 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,24 @@ jobs:
toolchain: ${{ matrix.rust }}
override: true

- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: ${{ matrix.os }}-${{ matrix.rust }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }}

- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: ${{ matrix.os }}-${{ matrix.rust }}-cargo-index-${{ hashFiles('**/Cargo.toml') }}

- name: Cache cargo build
uses: actions/cache@v1
with:
path: target
key: ${{ matrix.os }}-${{ matrix.rust }}-cargo-build-target-${{ hashFiles('**/Cargo.toml') }}

- name: check
uses: actions-rs/cargo@v1
with:
Expand All @@ -40,6 +58,14 @@ jobs:
with:
command: check
args: --features unstable --all --bins --examples --tests

- name: check wasm
uses: actions-rs/cargo@v1
with:
command: check
target: wasm32-unknown-unknown
override: true
args: --features unstable --all --bins --tests

- name: check bench
uses: actions-rs/cargo@v1
Expand All @@ -66,12 +92,6 @@ jobs:
command: test
args: --all --features "unstable attributes"

- name: documentation test
uses: actions-rs/cargo@v1
with:
command: test
args: --doc --features "unstable attributes"

build__with_no_std:
name: Build with no-std
runs-on: ubuntu-latest
Expand All @@ -90,6 +110,39 @@ jobs:
command: check
args: --no-default-features --features alloc --target thumbv7m-none-eabi -Z avoid-dev-deps

cross:
name: Cross compile
runs-on: ubuntu-latest
strategy:
matrix:
target:
- i686-unknown-linux-gnu
- powerpc-unknown-linux-gnu
- powerpc64-unknown-linux-gnu
- mips-unknown-linux-gnu
- arm-linux-androideabi

steps:
- uses: actions/checkout@master

- name: Install nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true

- name: Install cross
run: cargo install cross

- name: check
run: cross check --all --target ${{ matrix.target }}

- name: check unstable
run: cross check --all --features unstable --target ${{ matrix.target }}

- name: test
run: cross test --all --features unstable --target ${{ matrix.target }}

check_fmt_and_docs:
name: Checking fmt and docs
runs-on: ubuntu-latest
Expand Down Expand Up @@ -117,15 +170,3 @@ jobs:

- name: Docs
run: cargo doc --features docs

# clippy_check:
# name: Clippy check
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v1
# - name: Install rust
# run: rustup update beta && rustup default beta
# - name: Install clippy
# run: rustup component add clippy
# - name: clippy
# run: cargo clippy --all --features unstable
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,30 @@ and this project adheres to [Semantic Versioning](https://book.async.rs/overview

## [Unreleased]

## Changed

- For `wasm`, switched underlying `Timer` implementation to [`futures-timer`](https://github.com/async-rs/futures-timer). ([#776](https://github.com/async-rs/async-std/pull/776))

# [1.6.0-beta.1] - 2020-05-07

## Added

- Added `task::spawn_local`. ([#757](https://github.com/async-rs/async-std/pull/757))
- Added out of the box support for `wasm`. ([#757](https://github.com/async-rs/async-std/pull/757))
- Added `JoinHandle::cancel` ([#757](https://github.com/async-rs/async-std/pull/757))
- Added `sync::Condvar` ([#369](https://github.com/async-rs/async-std/pull/369))
- Added `sync::Sender::try_send` and `sync::Receiver::try_recv` ([#585](https://github.com/async-rs/async-std/pull/585))
- Added `no_std` support for `task`, `future` and `stream` ([#680](https://github.com/async-rs/async-std/pull/680))

## Changed

- Switched underlying runtime to [`smol`](https://github.com/stjepang/smol/). ([#757](https://github.com/async-rs/async-std/pull/757))
- Switched implementation of `sync::Barrier` to use `sync::Condvar` like `std` does. ([#581](https://github.com/async-rs/async-std/pull/581))

## Fixed

- Allow compilation on 32 bit targets, by using `AtomicUsize` for `TaskId`. ([#756](https://github.com/async-rs/async-std/pull/756))

# [1.5.0] - 2020-02-03

[API Documentation](https://docs.rs/async-std/1.5.0/async-std)
Expand Down Expand Up @@ -678,6 +702,7 @@ task::blocking(async {
- Initial beta release

[Unreleased]: https://github.com/async-rs/async-std/compare/v1.5.0...HEAD
[1.6.0-beta.1]: https://github.com/async-rs/async-std/compare/v1.4.0...v1.6.0-beta.1
[1.5.0]: https://github.com/async-rs/async-std/compare/v1.4.0...v1.5.0
[1.4.0]: https://github.com/async-rs/async-std/compare/v1.3.0...v1.4.0
[1.3.0]: https://github.com/async-rs/async-std/compare/v1.2.0...v1.3.0
Expand Down
58 changes: 35 additions & 23 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[package]
name = "async-std"
version = "1.5.0"
version = "1.6.0-beta.1"
authors = [
"Stjepan Glavina <[email protected]>",
"Yoshua Wuyts <[email protected]>",
"Friedel Ziegelmayer <[email protected]>",
"Contributors to async-std",
]
edition = "2018"
Expand All @@ -24,18 +25,13 @@ rustdoc-args = ["--cfg", "feature=\"docs\""]
default = [
"std",
"async-task",
"crossbeam-channel",
"crossbeam-deque",
"futures-timer",
"kv-log-macro",
"log",
"mio",
"mio-uds",
"num_cpus",
"pin-project-lite",
]
docs = ["attributes", "unstable", "default"]
unstable = ["std", "broadcaster", "futures-timer"]
unstable = ["std"]
attributes = ["async-attributes"]
std = [
"alloc",
Expand All @@ -46,6 +42,10 @@ std = [
"once_cell",
"pin-utils",
"slab",
"smol",
"futures-timer",
"wasm-bindgen-futures",
"futures-channel",
]
alloc = [
"futures-core/alloc",
Expand All @@ -54,31 +54,39 @@ alloc = [

[dependencies]
async-attributes = { version = "1.1.1", optional = true }
async-task = { version = "1.2.1", optional = true }
broadcaster = { version = "1.0.0", optional = true }
crossbeam-channel = { version = "0.4.0", optional = true }
crossbeam-deque = { version = "0.7.2", optional = true }
crossbeam-utils = { version = "0.7.0", optional = true }
futures-core = { version = "0.3.1", optional = true, default-features = false }
futures-io = { version = "0.3.1", optional = true }
futures-timer = { version = "2.0.2", optional = true }
async-task = { version = "3.0.0", optional = true }
crossbeam-utils = { version = "0.7.2", optional = true }
futures-core = { version = "0.3.4", optional = true, default-features = false }
futures-io = { version = "0.3.4", optional = true }
kv-log-macro = { version = "1.0.4", optional = true }
log = { version = "0.4.8", features = ["kv_unstable"], optional = true }
memchr = { version = "2.3.0", optional = true }
mio = { version = "0.6.19", optional = true }
mio-uds = { version = "0.6.7", optional = true }
num_cpus = { version = "1.11.1", optional = true }
once_cell = { version = "1.2.0", optional = true }
pin-project-lite = { version = "0.1.2", optional = true }
memchr = { version = "2.3.3", optional = true }
num_cpus = { version = "1.12.0", optional = true }
once_cell = { version = "1.3.1", optional = true }
pin-project-lite = { version = "0.1.4", optional = true }
pin-utils = { version = "0.1.0-alpha.4", optional = true }
slab = { version = "0.4.2", optional = true }

# Devdepencency, but they are not allowed to be optional :/
surf = { version = "1.0.3", optional = true }

[target.'cfg(not(target_os = "unknown"))'.dependencies]
smol = { version = "0.1.1", optional = true }

[target.'cfg(target_arch = "wasm32")'.dependencies]
futures-timer = { version = "3.0.2", optional = true, features = ["wasm-bindgen"] }
wasm-bindgen-futures = { version = "0.4.10", optional = true }
futures-channel = { version = "0.3.4", optional = true }

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test = "0.3.10"

[dev-dependencies]
femme = "1.3.0"
rand = "0.7.3"
surf = "1.0.3"
tempdir = "0.3.7"
futures = "0.3.1"
futures = "0.3.4"
rand_xorshift = "0.2.0"

[[test]]
name = "stream"
Expand All @@ -87,3 +95,7 @@ required-features = ["unstable"]
[[example]]
name = "tcp-ipv4-and-6-echo"
required-features = ["unstable"]

[[example]]
name = "surf-web"
required-features = ["surf"]
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
<br />

<div align="center">
<!-- CI status -->
<a href="https://github.com/async-rs/async-std/actions">
<img src="https://github.com/async-rs/async-std/workflows/CI/badge.svg"
alt="CI Status" />
</a>
<!-- Crates version -->
<a href="https://crates.io/crates/async-std">
<img src="https://img.shields.io/crates/v/async-std.svg?style=flat-square"
Expand Down Expand Up @@ -136,6 +141,8 @@ documentation] on how to enable them.

* [Xactor](https://crates.io/crates/xactor) — Xactor is a rust actors framework based on async-std.

* [async-graphql](https://crates.io/crates/async-graphql) — A GraphQL server library implemented in rust, with full support for async/await.

## License

<sup>
Expand Down
16 changes: 14 additions & 2 deletions src/fs/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::future;
use crate::io::{self, Read, Seek, SeekFrom, Write};
use crate::path::Path;
use crate::prelude::*;
use crate::task::{self, spawn_blocking, Context, Poll, Waker};
use crate::task::{spawn_blocking, Context, Poll, Waker};
use crate::utils::Context as _;

/// An open file on the filesystem.
Expand Down Expand Up @@ -315,7 +315,7 @@ impl Drop for File {
// non-blocking fashion, but our only other option here is losing data remaining in the
// write cache. Good task schedulers should be resilient to occasional blocking hiccups in
// file destructors so we don't expect this to be a common problem in practice.
let _ = task::block_on(self.flush());
let _ = smol::block_on(self.flush());
}
}

Expand Down Expand Up @@ -867,3 +867,15 @@ impl LockGuard<State> {
Poll::Ready(Ok(()))
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn async_file_drop() {
crate::task::block_on(async move {
File::open(file!()).await.unwrap();
});
}
}
6 changes: 3 additions & 3 deletions src/future/future/delay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use std::future::Future;
use std::pin::Pin;
use std::time::Duration;

use futures_timer::Delay;
use pin_project_lite::pin_project;

use crate::task::{Context, Poll};
use crate::utils::Timer;

pin_project! {
#[doc(hidden)]
Expand All @@ -14,13 +14,13 @@ pin_project! {
#[pin]
future: F,
#[pin]
delay: Delay,
delay: Timer,
}
}

impl<F> DelayFuture<F> {
pub fn new(future: F, dur: Duration) -> DelayFuture<F> {
let delay = Delay::new(dur);
let delay = Timer::after(dur);

DelayFuture { future, delay }
}
Expand Down
17 changes: 8 additions & 9 deletions src/future/timeout.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use std::error::Error;
use std::fmt;
use std::future::Future;
use std::pin::Pin;
use std::time::Duration;
use std::future::Future;

use futures_timer::Delay;
use pin_project_lite::pin_project;

use crate::task::{Context, Poll};
use crate::utils::Timer;

/// Awaits a future or times out after a duration of time.
///
Expand All @@ -33,11 +33,7 @@ pub async fn timeout<F, T>(dur: Duration, f: F) -> Result<T, TimeoutError>
where
F: Future<Output = T>,
{
let f = TimeoutFuture {
future: f,
delay: Delay::new(dur),
};
f.await
TimeoutFuture::new(f, dur).await
}

pin_project! {
Expand All @@ -46,14 +42,17 @@ pin_project! {
#[pin]
future: F,
#[pin]
delay: Delay,
delay: Timer,
}
}

impl<F> TimeoutFuture<F> {
#[allow(dead_code)]
pub(super) fn new(future: F, dur: Duration) -> TimeoutFuture<F> {
TimeoutFuture { future: future, delay: Delay::new(dur) }
TimeoutFuture {
future,
delay: Timer::after(dur),
}
}
}

Expand Down
Loading

0 comments on commit d30603a

Please sign in to comment.