Julio Biason
6 months ago
3 changed files with 194 additions and 0 deletions
@ -0,0 +1,174 @@
|
||||
# This file is automatically @generated by Cargo. |
||||
# It is not intended for manual editing. |
||||
version = 3 |
||||
|
||||
[[package]] |
||||
name = "addr2line" |
||||
version = "0.21.0" |
||||
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||
checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" |
||||
dependencies = [ |
||||
"gimli", |
||||
] |
||||
|
||||
[[package]] |
||||
name = "adler" |
||||
version = "1.0.2" |
||||
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" |
||||
|
||||
[[package]] |
||||
name = "backtrace" |
||||
version = "0.3.71" |
||||
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||
checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" |
||||
dependencies = [ |
||||
"addr2line", |
||||
"cc", |
||||
"cfg-if", |
||||
"libc", |
||||
"miniz_oxide", |
||||
"object", |
||||
"rustc-demangle", |
||||
] |
||||
|
||||
[[package]] |
||||
name = "cc" |
||||
version = "1.0.97" |
||||
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||
checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4" |
||||
|
||||
[[package]] |
||||
name = "cfg-if" |
||||
version = "1.0.0" |
||||
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" |
||||
|
||||
[[package]] |
||||
name = "gimli" |
||||
version = "0.28.1" |
||||
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||
checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" |
||||
|
||||
[[package]] |
||||
name = "hermit-abi" |
||||
version = "0.3.9" |
||||
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||
checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" |
||||
|
||||
[[package]] |
||||
name = "libc" |
||||
version = "0.2.154" |
||||
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||
checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" |
||||
|
||||
[[package]] |
||||
name = "memchr" |
||||
version = "2.7.2" |
||||
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||
checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" |
||||
|
||||
[[package]] |
||||
name = "miniz_oxide" |
||||
version = "0.7.2" |
||||
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||
checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" |
||||
dependencies = [ |
||||
"adler", |
||||
] |
||||
|
||||
[[package]] |
||||
name = "num_cpus" |
||||
version = "1.16.0" |
||||
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||
checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" |
||||
dependencies = [ |
||||
"hermit-abi", |
||||
"libc", |
||||
] |
||||
|
||||
[[package]] |
||||
name = "object" |
||||
version = "0.32.2" |
||||
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||
checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" |
||||
dependencies = [ |
||||
"memchr", |
||||
] |
||||
|
||||
[[package]] |
||||
name = "pin-project-lite" |
||||
version = "0.2.14" |
||||
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||
checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" |
||||
|
||||
[[package]] |
||||
name = "proc-macro2" |
||||
version = "1.0.82" |
||||
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||
checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" |
||||
dependencies = [ |
||||
"unicode-ident", |
||||
] |
||||
|
||||
[[package]] |
||||
name = "quote" |
||||
version = "1.0.36" |
||||
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" |
||||
dependencies = [ |
||||
"proc-macro2", |
||||
] |
||||
|
||||
[[package]] |
||||
name = "rustc-demangle" |
||||
version = "0.1.24" |
||||
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||
checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" |
||||
|
||||
[[package]] |
||||
name = "syn" |
||||
version = "2.0.63" |
||||
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||
checksum = "bf5be731623ca1a1fb7d8be6f261a3be6d3e2337b8a1f97be944d020c8fcb704" |
||||
dependencies = [ |
||||
"proc-macro2", |
||||
"quote", |
||||
"unicode-ident", |
||||
] |
||||
|
||||
[[package]] |
||||
name = "tokio" |
||||
version = "1.37.0" |
||||
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||
checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" |
||||
dependencies = [ |
||||
"backtrace", |
||||
"num_cpus", |
||||
"pin-project-lite", |
||||
"tokio-macros", |
||||
] |
||||
|
||||
[[package]] |
||||
name = "tokio-macros" |
||||
version = "2.2.0" |
||||
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||
checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" |
||||
dependencies = [ |
||||
"proc-macro2", |
||||
"quote", |
||||
"syn", |
||||
] |
||||
|
||||
[[package]] |
||||
name = "tokiosemaphoretest" |
||||
version = "0.1.0" |
||||
dependencies = [ |
||||
"tokio", |
||||
] |
||||
|
||||
[[package]] |
||||
name = "unicode-ident" |
||||
version = "1.0.12" |
||||
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" |
@ -0,0 +1,7 @@
|
||||
[package] |
||||
name = "tokiosemaphoretest" |
||||
version = "0.1.0" |
||||
edition = "2021" |
||||
|
||||
[dependencies] |
||||
tokio = { version = "1.37.0", features = ["rt", "rt-multi-thread", "macros", "sync"] } |
@ -0,0 +1,13 @@
|
||||
use tokio::sync::Semaphore; |
||||
|
||||
#[tokio::main] |
||||
async fn main() { |
||||
let sem = Semaphore::new(4); |
||||
|
||||
let _p = sem.acquire_many(3).await; |
||||
println!("P acquired: {_p:?}"); |
||||
|
||||
// this locks :(
|
||||
let _q = sem.acquire_many(12).await; |
||||
println!("12 acquired: {_q:?}"); |
||||
} |
Loading…
Reference in new issue