Skip to content

Commit

Permalink
feat(maitake): introduce a separate maitake-sync crate (#462)
Browse files Browse the repository at this point in the history
The `maitake` crate provides async synchronization primitives in a
`maitake::sync` module. These APIs don't require the rest of the
runtime, and would be nice to be able to use in other crates. `maitake`
is not yet published to crates.io, as it contains Git-only dependencies.
However, the `sync` module can be implemented entirely using published
code, and therefore, a crate containing only `maitake::sync` could be
published.

This branch introduces a new `maitake-sync` crate, containing the
synchronization primitives from `maitake::sync`. The `maitake::sync`
module now re-exports `maitake-sync`, so there should be no impact for
existing uses of the crate. The new `maitake-sync` crate can easily be
published to crates.io, and depended on from released code.
  • Loading branch information
hawkw authored Sep 4, 2023
1 parent 230afdb commit 8d85472
Show file tree
Hide file tree
Showing 49 changed files with 2,740 additions and 765 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ jobs:
maitake:
paths:
- 'maitake/**/*.rs'
- 'maitake-sync/**/*.rs'
- 'maitake-sync/Cargo.toml'
- 'maitake/Cargo.toml'
- '.github/workflows/ci.yml'
- 'justfile'
Expand Down Expand Up @@ -275,8 +277,10 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: install nextest
uses: taiki-e/install-action@nextest
- name: run loom tests
- name: run loom tests (maitake)
run: just loom maitake
- name: run loom tests (maitake-sync)
run: just loom maitake-sync

### mycelium-util ###

Expand Down
63 changes: 46 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ members = [
"hal-x86_64",
"inoculate",
"maitake",
"maitake-sync",
"mycotest",
"trace",
"pci",
Expand Down
2 changes: 1 addition & 1 deletion cordyceps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ tracing-subscriber = { version = "0.3", features = ["fmt"] }
pin-project = "1"

[target.'cfg(loom)'.dependencies]
loom = "0.5.5"
loom = "0.7"
tracing = { version = "0.1" }

[package.metadata.docs.rs]
Expand Down
58 changes: 58 additions & 0 deletions maitake-sync/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
[package]
name = "maitake-sync"
version = "0.1.0"
authors = [
"Eliza Weisman <[email protected]>",
]
description = "No-std async synchronization primitives from Maitake"
repository = "https://github.com/hawkw/mycelium"
documentation = "https://docs.rs/maitake-sync"
homepage = "https://mycelium.elizas.website"
license = "MIT"
readme = "README.md"
keywords = ["async", "no_std", "sync", "mutex", "rwlock"]
categories = [
"no-std",
"async",
"concurrency"
]
edition = "2021"
rust-version = "1.61.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
default = ["alloc"]
alloc = ["cordyceps/alloc"]
no-cache-pad = ["cordyceps/no-cache-pad"]
core-error = []

[dependencies]
mycelium-bitfield = { version = "0.1.3", path = "../bitfield" }
cordyceps = { version = "0.3.0", path = "../cordyceps" }
pin-project = "1"
portable-atomic = "1.2"
tracing = { version = "0.1", default_features = false, optional = true }

# this is a normal dependency, rather than a dev dependency, so that
# `maitake-sync` may be used in other crates' loom tests as well (but only when
# the cfg is enabled).
[target.'cfg(loom)'.dependencies]
loom = { version = "0.7", default_features = false }

[dev-dependencies]
futures-util = "0.3"
futures = "0.3"
tokio-test = "0.4"
tracing = { version = "0.1", default_features = false, features = ["std"] }
tracing-subscriber = { version = "0.3.11", features = ["fmt", "env-filter"] }

[target.'cfg(not(loom))'.dev-dependencies]
proptest = "1"
tokio = { version = "1.32", features = ["rt", "macros"] }

[target.'cfg(loom)'.dev-dependencies]
loom = { version = "0.7", features = ["futures", "checkpoint"] }

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
21 changes: 21 additions & 0 deletions maitake-sync/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Eliza Weisman

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit 8d85472

Please sign in to comment.