Skip to content

Commit

Permalink
Prepare new version
Browse files Browse the repository at this point in the history
  • Loading branch information
AldaronLau committed Jun 19, 2024
1 parent 8c69c16 commit 77c7736
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 23 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to `whisk` will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://github.com/AldaronLau/semver).

## [0.13.0] - 2024-06-19
### Changed
- Switched out `pasts` for `event_iterator`
- Renamed `futures-core` feature to `futures_core_3`

## [0.12.1] - 2023-06-02
### Fixed
- Weirdness with `Cargo.toml`'s `[[example]]` section and no-std example in CI.
Expand Down
16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Whisk
# Copyright © 2022-2023 Jeron Aldaron Lau.
# Copyright © 2022-2024 Jeron Aldaron Lau.
#
# Licensed under any of:
# - Apache License, Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0)
Expand All @@ -10,7 +10,7 @@

[package]
name = "whisk"
version = "0.12.1"
version = "0.13.0"
license = "Apache-2.0 OR BSL-1.0 OR MIT"
description = "Simple and fast lockless async channels"
repository = "https://github.com/ardaku/whisk"
Expand All @@ -24,24 +24,24 @@ categories = [
"hardware-support",
"no-std",
]
keywords = ["channel", "actor", "mpmc", "notifier", "pasts"]
keywords = ["channel", "actor", "mpmc", "notifier", "event_iterator"]
readme = "README.md"
edition = "2021"
rust-version = "1.65"

[[example]]
name = "tokio"
required-features = ["futures-core"]
required-features = ["futures_core_3"]

[dependencies.futures-core]
[dependencies.futures_core_3]
package = "futures-core"
version = "0.3"
optional = true
default-features = false

[dependencies.pasts]
version = "0.14"
[dependencies.event_iterator]
version = "0.1"
optional = true
default-features = false

[dev-dependencies]
async_main = { version = "0.4", features = ["pasts"] }
Expand Down
2 changes: 1 addition & 1 deletion examples/no-std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ default-features = false

[dependencies.whisk]
version = "0.12"
features = ["pasts"]
features = ["event_iterator"]
2 changes: 1 addition & 1 deletion examples/tokio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
task::{Context, Poll},
};

use futures_core::Stream;
use futures_core_3::Stream;
use tokio::task;
use tokio_stream::StreamExt;
use whisk::Channel;
Expand Down
26 changes: 15 additions & 11 deletions src/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ use crate::{wake_list::WakeHandle, Queue};

/// An MPMC channel with both send and receive capabilities
///
/// Enable the **`futures-core`** feature for `Channel` to implement
/// [`Stream`](futures_core::Stream) (generic `T` must be `Option<Item>`).
/// Enable the **`futures_core_3`** feature for `Channel` to implement
/// [`Stream`](futures_core_3::Stream) (generic `T` must be `Option<Item>`).
///
/// Enable the **`pasts`** feature for `Channel` to implement
/// [`Notifier`](pasts::Notifier).
/// Enable the **`event_iterator`** feature for `Channel` to implement
/// [`EventIterator`](event_iterator::EventIterator).
pub struct Channel<T = (), U: ?Sized = ()>(Arc<Queue<T, U>>, WakeHandle);

impl<T, U: ?Sized> Drop for Channel<T, U> {
Expand Down Expand Up @@ -89,19 +89,23 @@ impl<T, U: ?Sized> Future for Channel<T, U> {
}
}

#[cfg(feature = "pasts")]
impl<T, U: ?Sized> pasts::notify::Notify for Channel<T, U> {
type Event = T;
#[cfg(feature = "event_iterator")]
impl<T, U: ?Sized> event_iterator::EventIterator for Channel<T, U> {
type Event<'me> = T where Self: 'me;

#[inline(always)]
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<T> {
fn poll_next(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Option<T>> {
let this = self.get_mut();
this.0.data.take(cx, &mut this.1)

this.0.data.take(cx, &mut this.1).map(Some)
}
}

#[cfg(feature = "futures-core")]
impl<T, U: ?Sized> futures_core::Stream for Channel<Option<T>, U> {
#[cfg(feature = "futures_core_3")]
impl<T, U: ?Sized> futures_core_3::Stream for Channel<Option<T>, U> {
type Item = T;

#[inline(always)]
Expand Down
5 changes: 3 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
//! receiver pairs. A [`Channel`] can both send and receive.
//!
//! # Optional Features
//! - **futures-core**: Implement [`Stream`](futures_core::Stream) for
//! - **futures_core_3**: Implement [`Stream`](futures_core_3::Stream) for
//! [`Channel`] (generic `T` must be `Option<Item>`)
//! - **pasts**: Implement [`Notifier`](pasts::Notifier) for [`Channel`]
//! - **event_iterator**: Implement
//! [`EventIterator`](event_iterator::EventIterator) for [`Channel`]
//!
//! # Getting Started
//!
Expand Down

0 comments on commit 77c7736

Please sign in to comment.