Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgraded to tokio. Fixed several issues
- Loading branch information
1 parent
301f598
commit 719df35
Showing
6 changed files
with
109 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,10 @@ | ||
# Generated by Cargo | ||
# will have compiled files and executables | ||
/target/ | ||
/target | ||
|
||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries | ||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html | ||
Cargo.lock | ||
|
||
# These are backup files generated by rustfmt | ||
**/*.rs.bk | ||
|
||
|
||
#Added by cargo | ||
# | ||
#already existing elements were commented out | ||
|
||
/target | ||
#Cargo.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,17 @@ | ||
[package] | ||
name = "slock" | ||
version = "0.1.2" | ||
authors = ["Brandon Dyer <BrandonDyer64@gmail.com>"] | ||
edition = "2018" | ||
categories = ["asynchronous", "concurrency", "memory-management", "rust-patterns"] | ||
description = "An async mutex that never deadlocks." | ||
edition = "2021" | ||
keywords = ["mutex", "smart", "lock", "async"] | ||
license = "MIT" | ||
name = "slock" | ||
readme = "README.md" | ||
repository = "https://github.com/BrokenLamp/slock-rs" | ||
license = "MIT" | ||
keywords = ["mutex", "smart", "lock", "async"] | ||
categories = ["asynchronous", "concurrency", "memory-management", "rust-patterns"] | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[features] | ||
default = ["futures", "blocking"] | ||
blocking = ["futures"] | ||
|
||
[dependencies.futures] | ||
version = "0.3" | ||
optional = true | ||
version = "0.2.0" | ||
|
||
[dependencies.async-std] | ||
version = "1.6" | ||
[dependencies] | ||
tokio = {version = "1.22", features = ["sync", "time", "rt", "macros"]} | ||
|
||
[dev-dependencies] | ||
lazy_static = "1.4" | ||
futures = "0.3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
use futures::executor::block_on; | ||
use slock::*; | ||
|
||
#[test] | ||
fn basic_hooks() { | ||
#[tokio::test] | ||
async fn basic_hooks() { | ||
// SAFETY: Required to increment the static counter | ||
unsafe { | ||
let lock = Slock::new(()); | ||
static mut COUNT: i32 = 0; | ||
lock.hook(|_| COUNT += 1); | ||
block_on(lock.set(|_| ())); | ||
block_on(lock.set(|_| ())); | ||
block_on(lock.set(|_| ())); | ||
lock.hook(|_| COUNT += 1).await; | ||
lock.set(|_| ()).await; | ||
lock.set(|_| ()).await; | ||
lock.set(|_| ()).await; | ||
assert_eq!(COUNT, 3); | ||
} | ||
} |
Oops, something went wrong.