Compare commits

9 Commits

Author SHA1 Message Date
bors[bot]
69cce123bf Merge #5
5: Prepare for 1.0.0 release r=bertptrs a=bertptrs



Co-authored-by: Bert Peters <bert@bertptrs.nl>
2023-04-17 06:37:22 +00:00
50b9489481 Prepare for 1.0.0 release 2023-04-17 08:35:49 +02:00
90e6a53024 Update copyright year 2023-03-11 13:17:07 +01:00
bors[bot]
b46631fda3 Merge #3
3: Make use of pin! stabilization r=bertptrs a=bertptrs

With Rust 1.68 `std::pin::pin!` is stable therefore we can now use it to get rid of a pesky heap allocation in the executor.

This requires bumping MSRV to 1.68, but I feel this should be the last time that will happen, so after this I can cut the 1.0.

Co-authored-by: Bert Peters <bert@bertptrs.nl>
2023-03-11 11:39:18 +00:00
b7e0f8e252 Increase MSRV to 1.68 2023-03-11 12:24:05 +01:00
44fe3f0e76 Make use of pin! stabilization 2023-03-11 12:14:21 +01:00
bors[bot]
a0966f70e9 Merge #2
2: Fix CI deprecation issues r=bertptrs a=bertptrs



Co-authored-by: Bert Peters <bert@bertptrs.nl>
2023-01-08 16:48:18 +00:00
d2990202bd Move away from deprecated actions-rs 2023-01-08 17:44:57 +01:00
1533071426 Move to checkout v3 2023-01-08 17:39:32 +01:00
6 changed files with 46 additions and 51 deletions

View File

@@ -17,34 +17,17 @@ jobs:
- stable
- beta
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
components: rustfmt, clippy
- uses: actions-rs/cargo@v1
with:
command: build
# --all-targets ensures that we also build tests
args: --all-features --all-targets
- uses: actions-rs/cargo@v1
with:
command: test
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets -- -D warnings
- run: cargo build --all-targets
- run: cargo test
- run: cargo fmt --all -- --check
- run: cargo clippy --all-targets -- -D warnings
# Reduced build for the Minimum Supported Rust Version. It does not include the lints as some of
# them are out-of-date and result in false positives on the codebase, e.g. mutex_atomic.
@@ -52,33 +35,24 @@ jobs:
name: MSRV
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@v1
with:
profile: minimal
toolchain: "1.51"
override: true
toolchain: "1.68"
- uses: actions-rs/cargo@v1
with:
command: test
- run: cargo test
miri:
name: Miri
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: miri, rust-src
- uses: actions-rs/cargo@v1
with:
command: miri
args: test
- run: cargo miri test

View File

@@ -6,6 +6,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [1.0.0] - 2023-04-17
### Changed
- Use dynamic dispatch internally to save on code gen. External API unchanged.
- No longer heap-allocate futures.
### Breaking
- Minimum supported Rust version bumped to 1.68.
## [0.1.1] - 2022-09-05
### Fixed
@@ -16,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Initial release
[Unreleased]: https://github.com/bertptrs/beul/compare/v0.1.1...HEAD
[Unreleased]: https://github.com/bertptrs/beul/compare/v1.0.0...HEAD
[1.0.0]: https://github.com/bertptrs/beul/compare/v0.1.1...v1.0.0
[0.1.1]: https://github.com/bertptrs/beul/compare/v0.1.0...v0.1.1
[0.1.0]: https://github.com/bertptrs/beul/releases/tag/v0.1.0

View File

@@ -1,12 +1,11 @@
[package]
name = "beul"
version = "0.1.1"
# Edition 2021 is not available in MSRV
edition = "2018"
version = "1.0.0"
edition = "2021"
license = "MIT OR Apache-2.0"
description = "It executes futures"
repository = "https://github.com/bertptrs/beul/"
rust-version = "1.51"
rust-version = "1.68"
authors = [
"Bert Peters",
]

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2022 Bert Peters
Copyright (c) 2023 Bert Peters
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,6 +1,9 @@
# Beul
Beul is a minimalistic futures executor. No dependencies, no unsafe rust.
Beul is a minimalistic futures executor. No dependencies, no unsafe rust. It simply executes
futures.
"Beul" is Dutch for executioner. It's a pun.
## Usage
@@ -12,8 +15,9 @@ beul::execute(async {});
### Backwards compatibility
This crate requires at least Rust 1.51, due to its reliance on [Wake]. Increases in this version
will be considered breaking changes. This crate follows semantic versioning.
This crate requires at least Rust 1.68, due to its reliance on [std::pin::pin!]. Increases in this
version will be considered breaking changes and will be avoided if possible. The minimum supported
Rust version will only be bumped in major or minor versions. This crate follows semantic versioning.
### Limitations
@@ -37,4 +41,4 @@ work by you, as defined in the Apache-2.0 license, shall be dual licensed as abo
additional terms or conditions.
[Tokio]: https://tokio.rs/
[Wake]: https://doc.rust-lang.org/std/task/trait.Wake.html
[std::pin::pin!]: https://doc.rust-lang.org/std/pin/macro.pin.html

View File

@@ -16,6 +16,7 @@
//! ```
#![forbid(unsafe_code)]
use std::future::Future;
use std::pin::Pin;
use std::sync::Arc;
use std::sync::Condvar;
use std::sync::Mutex;
@@ -60,10 +61,15 @@ impl Wake for CondvarWake {
}
/// Block on specified [`Future`].
///
/// The future will be polled until completion on the current thread.
pub fn execute<T>(f: impl Future<Output = T>) -> T {
// TODO: replace with std::pin::pin once it gets stabilized
let mut pinned = Box::pin(f);
// Use dynamic dispatch to save on codegen
poll(std::pin::pin!(f))
}
/// Poll a future until completion.
fn poll<T>(mut pinned: Pin<&mut dyn Future<Output = T>>) -> T {
let wake = Arc::new(CondvarWake::default());
let waker = Waker::from(Arc::clone(&wake));