id
stringlengths
22
133
text
stringlengths
40
40.2k
arch
stringclasses
1 value
syntax
stringclasses
1 value
kind
stringclasses
4 values
repo
stringclasses
27 values
path
stringlengths
5
116
license
stringclasses
6 values
commit
stringlengths
40
40
source_host
stringclasses
1 value
category
stringclasses
16 values
source_url
stringlengths
85
196
line_start
int64
1
4.28k
line_end
int64
4
4.31k
tokio-rs/tokio:tokio/tests/sync_panic.rs:1
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi")))] use std::{error::Error, sync::Arc}; use tokio::{ runtime::{Builder, Runtime}, sync::{broadcast, mpsc, oneshot, Mutex, RwLock, Semaphore}, }; mod support { pub mod panic; } use support::panic::test_panic; #[test] fn broadca...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_panic.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/sync_panic.rs
1
60
tokio-rs/tokio:tokio/tests/sync_panic.rs:2
} #[test] fn oneshot_blocking_recv_panic_caller() -> Result<(), Box<dyn Error>> { let panic_location_file = test_panic(|| { let rt = current_thread(); rt.block_on(async { let (_tx, rx) = oneshot::channel::<u8>(); let _ = rx.blocking_recv(); }); }); // The pa...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_panic.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/sync_panic.rs
41
100
tokio-rs/tokio:tokio/tests/sync_panic.rs:4
let _ = rx.blocking_recv(); }); }); // The panic location should be in this file assert_eq!(&panic_location_file.unwrap(), file!()); Ok(()) } #[test] fn mpsc_bounded_sender_blocking_send_panic_caller() -> Result<(), Box<dyn Error>> { let panic_location_file = test_panic(|| { let r...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_panic.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/sync_panic.rs
121
180
tokio-rs/tokio:tokio/tests/sync_panic.rs:5
} #[test] fn semaphore_merge_unrelated_owned_permits() -> Result<(), Box<dyn Error>> { let panic_location_file = test_panic(|| { let sem1 = Arc::new(Semaphore::new(42)); let sem2 = Arc::new(Semaphore::new(42)); let mut p1 = sem1.try_acquire_owned().unwrap(); let p2 = sem2.try_acquir...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_panic.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/sync_panic.rs
161
197
tokio-rs/tokio:tokio/tests/sync_panic.rs:1
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(tokio_wasi)))] use std::{error::Error, sync::Arc}; use tokio::{ runtime::{Builder, Runtime}, sync::{broadcast, mpsc, oneshot, Mutex, RwLock, Semaphore}, }; mod support { pub mod panic; } use support::panic::test_panic; #[test] fn broadcast_chann...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_panic.rs
MIT
909de088450a31d1c472adc44532dca4910765b2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/909de088450a31d1c472adc44532dca4910765b2/tokio/tests/sync_panic.rs
1
60
tokio-rs/tokio:tokio/tests/sync_panic.rs:1
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(tokio_wasi)))] use std::error::Error; use tokio::{ runtime::{Builder, Runtime}, sync::{broadcast, mpsc, oneshot, Mutex, RwLock}, }; mod support { pub mod panic; } use support::panic::test_panic; #[test] fn broadcast_channel_panic_caller() -> Res...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_panic.rs
MIT
a3411a412c3424df7dcd151441fe0435c0a92c9c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a3411a412c3424df7dcd151441fe0435c0a92c9c/tokio/tests/sync_panic.rs
1
60
tokio-rs/tokio:tokio/tests/sync_panic.rs:4
let _ = rx.blocking_recv(); }); }); // The panic location should be in this file assert_eq!(&panic_location_file.unwrap(), file!()); Ok(()) } #[test] fn mpsc_bounded_sender_blocking_send_panic_caller() -> Result<(), Box<dyn Error>> { let panic_location_file = test_panic(|| { let r...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_panic.rs
MIT
a3411a412c3424df7dcd151441fe0435c0a92c9c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a3411a412c3424df7dcd151441fe0435c0a92c9c/tokio/tests/sync_panic.rs
121
165
tokio-rs/tokio:tokio/tests/sync_panic.rs:1
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(tokio_wasi)))] use std::error::Error; use tokio::{ runtime::{Builder, Runtime}, sync::{broadcast, mpsc, oneshot, Mutex, RwLock}, }; mod support { pub mod panic; } use support::panic::test_panic; #[test] fn broadcast_channel_panic_caller() -> Res...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_panic.rs
MIT
ff6fbc327dcd8f8d023dbe7b684d9ca13ac3aec4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ff6fbc327dcd8f8d023dbe7b684d9ca13ac3aec4/tokio/tests/sync_panic.rs
1
60
tokio-rs/tokio:tokio/tests/sync_panic.rs:2
} #[test] fn oneshot_blocking_recv_panic_caller() -> Result<(), Box<dyn Error>> { let panic_location_file = test_panic(|| { let rt = basic(); rt.block_on(async { let (_tx, rx) = oneshot::channel::<u8>(); let _ = rx.blocking_recv(); }); }); // The panic locat...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_panic.rs
MIT
ff6fbc327dcd8f8d023dbe7b684d9ca13ac3aec4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ff6fbc327dcd8f8d023dbe7b684d9ca13ac3aec4/tokio/tests/sync_panic.rs
41
100
tokio-rs/tokio:tokio/tests/sync_panic.rs:3
// The panic location should be in this file assert_eq!(&panic_location_file.unwrap(), file!()); Ok(()) } #[test] fn rwlock_blocking_write_panic_caller() -> Result<(), Box<dyn Error>> { let panic_location_file = test_panic(|| { let rt = basic(); rt.block_on(async { let lock = R...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_panic.rs
MIT
ff6fbc327dcd8f8d023dbe7b684d9ca13ac3aec4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ff6fbc327dcd8f8d023dbe7b684d9ca13ac3aec4/tokio/tests/sync_panic.rs
81
140
tokio-rs/tokio:tokio/tests/sync_panic.rs:4
let _ = rx.blocking_recv(); }); }); // The panic location should be in this file assert_eq!(&panic_location_file.unwrap(), file!()); Ok(()) } #[test] fn mpsc_bounded_sender_blocking_send_panic_caller() -> Result<(), Box<dyn Error>> { let panic_location_file = test_panic(|| { let r...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_panic.rs
MIT
ff6fbc327dcd8f8d023dbe7b684d9ca13ac3aec4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ff6fbc327dcd8f8d023dbe7b684d9ca13ac3aec4/tokio/tests/sync_panic.rs
121
165
tokio-rs/tokio:tokio/tests/sync_panic.rs:1
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(tokio_wasi)))] use std::error::Error; use tokio::{ runtime::{Builder, Runtime}, sync::{broadcast, mpsc, oneshot, Mutex, RwLock}, }; mod support { pub mod panic; } use support::panic::test_panic; #[test] fn broadcast_channel_panic_caller() -> Res...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_panic.rs
MIT
b2ada60e701d5c9e6644cf8fc42a100774f8e23f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/sync_panic.rs
1
60
tokio-rs/tokio:tokio/tests/sync_panic.rs:1
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi")))] use std::error::Error; use tokio::{ runtime::{Builder, Runtime}, sync::{broadcast, mpsc, oneshot, Mutex, RwLock}, }; mod support { pub mod panic; } use support::panic::test_panic; #[test] fn broadcast_channel_panic_caller(...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_panic.rs
MIT
6d3f92dddc510e9276191cfab1b0432ce8248589
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/tests/sync_panic.rs
1
60
tokio-rs/tokio:tokio/tests/sync_panic.rs:1
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] use std::error::Error; use tokio::{ runtime::{Builder, Runtime}, sync::{broadcast, mpsc, oneshot, Mutex, RwLock}, }; mod support { pub mod panic; } use support::panic::test_panic; #[test] fn broadcast_channel_panic_caller() -> Result<(), Box<dyn Error>...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_panic.rs
MIT
4daeea8cad1ce8e67946bc0e17d499ab304b5ca2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/4daeea8cad1ce8e67946bc0e17d499ab304b5ca2/tokio/tests/sync_panic.rs
1
60
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:1
#![warn(rust_2018_idioms)] #![cfg(feature = "sync")] #[cfg(all(target_family = "wasm", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as test; #[cfg(all(target_family = "wasm", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; #[cfg(not(all(target_family = "...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_rwlock.rs
1
60
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:2
let mut t1 = spawn(rwlock.read()); let _g1 = assert_ready!(t1.poll()); let mut t2 = spawn(rwlock.write()); assert_pending!(t2.poll()); } // When there is an active exclusive owner, subsequent exclusive access should not be possible #[test] fn read_exclusive_pending() { let rwlock = RwLock::new(100); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_rwlock.rs
41
100
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:3
#[test] #[should_panic(expected = "a RwLock may not be created with 0 readers")] fn zero_max_readers() { RwLock::with_max_readers(100, 0); } #[test] #[should_panic(expected = "a RwLock may not be created with 0 readers")] fn zero_max_readers_const() { RwLock::const_with_max_readers(100, 0); } // When there is...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_rwlock.rs
81
140
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:4
fn write_read_shared_pending() { let rwlock = RwLock::new(100); let mut t1 = spawn(rwlock.read()); let _g1 = assert_ready!(t1.poll()); let mut t2 = spawn(rwlock.read()); let _g2 = assert_ready!(t2.poll()); let mut t3 = spawn(rwlock.write()); assert_pending!(t3.poll()); let mut t4 = sp...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_rwlock.rs
121
180
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:5
assert_eq!(result, 100); } // Acquire an uncontested RwLock in exclusive mode #[maybe_tokio_test] async fn write_uncontested() { let rwlock = RwLock::new(100); let mut result = rwlock.write().await; *result += 50; assert_eq!(*result, 150); } // RwLocks should be acquired in the order that their Future...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_rwlock.rs
161
220
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:6
let b1 = barrier.clone(); tokio::spawn(async move { stream::iter(0..1000) .for_each(move |_| { let rwlock = rwclone1.clone(); async move { let mut guard = rwlock.write().await; *guard += 2; } }) ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_rwlock.rs
201
260
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:7
b3.wait().await; }); let b4 = barrier.clone(); tokio::spawn(async move { stream::iter(0..1000) .for_each(move |_| { let rwlock = rwclone4.clone(); async move { let mut guard = rwlock.write().await; *guard += 7; ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_rwlock.rs
241
300
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:8
let rg2 = lock.try_read().unwrap(); assert_eq!(*rg2, 15) } { let mut wg = lock.try_write().unwrap(); *wg = 1515; assert!(lock.try_read().is_err()) } assert_eq!(*lock.try_read().unwrap(), 1515); } #[maybe_tokio_test] async fn downgrade_map() { let lock = RwLock::ne...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_rwlock.rs
281
340
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:9
let write_guard = lock.write().await; let mut read_t = spawn(lock.read()); // We can't create a read when a write exists assert_pending!(read_t.poll()); // During the call to `f`, `read_t` doesn't have access yet. let write_guard = RwLockWriteGuard::try_downgrade_map(write_guard, |_| { ass...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_rwlock.rs
321
344
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:2
let mut t1 = spawn(rwlock.read()); let _g1 = assert_ready!(t1.poll()); let mut t2 = spawn(rwlock.write()); assert_pending!(t2.poll()); } // When there is an active exclusive owner, subsequent exclusive access should not be possible #[test] fn read_exclusive_pending() { let rwlock = RwLock::new(100); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/sync_rwlock.rs
41
100
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:3
// When there is an active exclusive owner, subsequent exclusive access should not be possible #[test] fn write_exclusive_pending() { let rwlock = RwLock::new(100); let mut t1 = spawn(rwlock.write()); let _g1 = assert_ready!(t1.poll()); let mut t2 = spawn(rwlock.write()); assert_pending!(t2.poll())...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/sync_rwlock.rs
81
140
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:4
assert_pending!(t4.poll()); } // when there is an active shared owner, and exclusive access is triggered, // reading should be possible after pending exclusive access is dropped #[test] fn write_read_shared_drop_pending() { let rwlock = RwLock::new(100); let mut t1 = spawn(rwlock.read()); let _g1 = assert_...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/sync_rwlock.rs
121
180
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:5
// RwLocks should be acquired in the order that their Futures are waited upon. #[maybe_tokio_test] async fn write_order() { let rwlock = RwLock::<Vec<u32>>::new(vec![]); let fut2 = rwlock.write().map(|mut guard| guard.push(2)); let fut1 = rwlock.write().map(|mut guard| guard.push(1)); fut1.await; fu...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/sync_rwlock.rs
161
220
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:6
b1.wait().await; }); let b2 = barrier.clone(); tokio::spawn(async move { stream::iter(0..1000) .for_each(move |_| { let rwlock = rwclone2.clone(); async move { let mut guard = rwlock.write().await; *guard += 3; ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/sync_rwlock.rs
201
260
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:7
}) .await; b4.wait().await; }); barrier.wait().await; let g = rwlock.read().await; assert_eq!(*g, 17_000); } #[maybe_tokio_test] async fn try_write() { let lock = RwLock::new(0); let read_guard = lock.read().await; assert!(lock.try_write().is_err()); drop(read_guard...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/sync_rwlock.rs
241
300
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:8
assert_eq!(*lock.try_read().unwrap(), 1515); } #[maybe_tokio_test] async fn downgrade_map() { let lock = RwLock::new(0); let write_guard = lock.write().await; let mut read_t = spawn(lock.read()); // We can't create a read when a write exists assert_pending!(read_t.poll()); // During the call ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/sync_rwlock.rs
281
332
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:9
// After `f` returns `None`, `read_t` doesn't have access assert_pending!(read_t.poll()); // After `f` returns `Some`, `read_t` does have access let read_guard1 = RwLockWriteGuard::try_downgrade_map(write_guard, |v| Some(v)) .expect("downgrade didn't succeed"); let read_guard2 = assert_ready!(r...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
161b8c80d58a4a070c7f41db18d43ea258737db7
github
async-runtime
https://github.com/tokio-rs/tokio/blob/161b8c80d58a4a070c7f41db18d43ea258737db7/tokio/tests/sync_rwlock.rs
321
332
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:4
assert_pending!(t4.poll()); } // when there is an active shared owner, and exclusive access is triggered, // reading should be possible after pending exclusive access is dropped #[test] fn write_read_shared_drop_pending() { let rwlock = RwLock::new(100); let mut t1 = spawn(rwlock.read()); let _g1 = assert_...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/sync_rwlock.rs
121
180
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:5
// RwLocks should be acquired in the order that their Futures are waited upon. #[maybe_tokio_test] async fn write_order() { let rwlock = RwLock::<Vec<u32>>::new(vec![]); let fut2 = rwlock.write().map(|mut guard| guard.push(2)); let fut1 = rwlock.write().map(|mut guard| guard.push(1)); fut1.await; fu...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/sync_rwlock.rs
161
220
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:6
}); let b2 = barrier.clone(); tokio::spawn(async move { stream::iter(0..1000) .for_each(move |_| { let rwlock = rwclone2.clone(); async move { let mut guard = rwlock.write().await; *guard += 3; } ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/sync_rwlock.rs
201
260
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:7
.await; b4.wait().await; }); barrier.wait().await; let g = rwlock.read().await; assert_eq!(*g, 17_000); } #[maybe_tokio_test] async fn try_write() { let lock = RwLock::new(0); let read_guard = lock.read().await; assert!(lock.try_write().is_err()); drop(read_guard); assert!(...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/sync_rwlock.rs
241
300
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:8
} #[maybe_tokio_test] async fn downgrade_map() { let lock = RwLock::new(0); let write_guard = lock.write().await; let mut read_t = spawn(lock.read()); // We can't create a read when a write exists assert_pending!(read_t.poll()); // During the call to `f`, `read_t` doesn't have access yet. ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/sync_rwlock.rs
281
331
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:1
#![warn(rust_2018_idioms)] #![cfg(feature = "sync")] #[cfg(tokio_wasm_not_wasi)] use wasm_bindgen_test::wasm_bindgen_test as test; #[cfg(tokio_wasm_not_wasi)] use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; #[cfg(not(tokio_wasm_not_wasi))] use tokio::test as maybe_tokio_test; use std::task::Poll; use ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
002f4a28c882d127a665bb8d71f751d4eb5e1b22
github
async-runtime
https://github.com/tokio-rs/tokio/blob/002f4a28c882d127a665bb8d71f751d4eb5e1b22/tokio/tests/sync_rwlock.rs
1
60
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:4
assert_pending!(t4.poll()); } // when there is an active shared owner, and exclusive access is triggered, // reading should be possible after pending exclusive access is dropped #[test] fn write_read_shared_drop_pending() { let rwlock = RwLock::new(100); let mut t1 = spawn(rwlock.read()); let _g1 = assert_...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
002f4a28c882d127a665bb8d71f751d4eb5e1b22
github
async-runtime
https://github.com/tokio-rs/tokio/blob/002f4a28c882d127a665bb8d71f751d4eb5e1b22/tokio/tests/sync_rwlock.rs
121
180
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:5
// RwLocks should be acquired in the order that their Futures are waited upon. #[maybe_tokio_test] async fn write_order() { let rwlock = RwLock::<Vec<u32>>::new(vec![]); let fut2 = rwlock.write().map(|mut guard| guard.push(2)); let fut1 = rwlock.write().map(|mut guard| guard.push(1)); fut1.await; fu...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
002f4a28c882d127a665bb8d71f751d4eb5e1b22
github
async-runtime
https://github.com/tokio-rs/tokio/blob/002f4a28c882d127a665bb8d71f751d4eb5e1b22/tokio/tests/sync_rwlock.rs
161
220
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:1
#![warn(rust_2018_idioms)] #![cfg(feature = "sync")] #[cfg(tokio_wasm_not_wasi)] use wasm_bindgen_test::wasm_bindgen_test as test; #[cfg(tokio_wasm_not_wasi)] use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; #[cfg(not(tokio_wasm_not_wasi))] use tokio::test as maybe_tokio_test; use std::task::Poll; use ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
ff6fbc327dcd8f8d023dbe7b684d9ca13ac3aec4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ff6fbc327dcd8f8d023dbe7b684d9ca13ac3aec4/tokio/tests/sync_rwlock.rs
1
60
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:7
.await; b4.wait().await; }); barrier.wait().await; let g = rwlock.read().await; assert_eq!(*g, 17_000); } #[maybe_tokio_test] async fn try_write() { let lock = RwLock::new(0); let read_guard = lock.read().await; assert!(lock.try_write().is_err()); drop(read_guard); assert!(...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
ff6fbc327dcd8f8d023dbe7b684d9ca13ac3aec4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ff6fbc327dcd8f8d023dbe7b684d9ca13ac3aec4/tokio/tests/sync_rwlock.rs
241
281
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:1
#![warn(rust_2018_idioms)] #![cfg(feature = "sync")] #[cfg(tokio_wasm_not_wasi)] use wasm_bindgen_test::wasm_bindgen_test as test; #[cfg(tokio_wasm_not_wasi)] use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; #[cfg(not(tokio_wasm_not_wasi))] use tokio::test as maybe_tokio_test; use std::task::Poll; use ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
b2ada60e701d5c9e6644cf8fc42a100774f8e23f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/sync_rwlock.rs
1
60
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:2
let mut t1 = spawn(rwlock.read()); let _g1 = assert_ready!(t1.poll()); let mut t2 = spawn(rwlock.write()); assert_pending!(t2.poll()); } // When there is an active exclusive owner, subsequent exclusive access should not be possible #[test] fn read_exclusive_pending() { let rwlock = RwLock::new(100); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
b2ada60e701d5c9e6644cf8fc42a100774f8e23f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/sync_rwlock.rs
41
100
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:3
// When there is an active exclusive owner, subsequent exclusive access should not be possible #[test] fn write_exclusive_pending() { let rwlock = RwLock::new(100); let mut t1 = spawn(rwlock.write()); let _g1 = assert_ready!(t1.poll()); let mut t2 = spawn(rwlock.write()); assert_pending!(t2.poll())...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
b2ada60e701d5c9e6644cf8fc42a100774f8e23f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/sync_rwlock.rs
81
140
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:4
assert_pending!(t4.poll()); } // when there is an active shared owner, and exclusive access is triggered, // reading should be possible after pending exclusive access is dropped #[test] fn write_read_shared_drop_pending() { let rwlock = RwLock::new(100); let mut t1 = spawn(rwlock.read()); let _g1 = assert_...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
b2ada60e701d5c9e6644cf8fc42a100774f8e23f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/sync_rwlock.rs
121
180
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:1
#![warn(rust_2018_idioms)] #![cfg(feature = "sync")] #[cfg(all(target_family = "wasm", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as test; #[cfg(all(target_family = "wasm", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; #[cfg(not(all(target_family = "...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
0dc62da21b0bffe113e2efa23f6da6ef4e36bf4f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0dc62da21b0bffe113e2efa23f6da6ef4e36bf4f/tokio/tests/sync_rwlock.rs
1
60
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:4
assert_pending!(t4.poll()); } // when there is an active shared owner, and exclusive access is triggered, // reading should be possible after pending exclusive access is dropped #[test] fn write_read_shared_drop_pending() { let rwlock = RwLock::new(100); let mut t1 = spawn(rwlock.read()); let _g1 = assert_...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
0dc62da21b0bffe113e2efa23f6da6ef4e36bf4f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0dc62da21b0bffe113e2efa23f6da6ef4e36bf4f/tokio/tests/sync_rwlock.rs
121
180
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:1
#![warn(rust_2018_idioms)] #![cfg(feature = "sync")] #[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as test; #[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; #[cfg(not(all(target_arch = "wa...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
6d3f92dddc510e9276191cfab1b0432ce8248589
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/tests/sync_rwlock.rs
1
60
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:1
#![warn(rust_2018_idioms)] #![cfg(feature = "sync")] #[cfg(target_arch = "wasm32")] use wasm_bindgen_test::wasm_bindgen_test as test; #[cfg(target_arch = "wasm32")] use wasm_bindgen_test::wasm_bindgen_test as maybe_tokio_test; #[cfg(not(target_arch = "wasm32"))] use tokio::test as maybe_tokio_test; use std::task::Po...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
2747043f6f7e0870cc5aa72c146dfae9543c5ba8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2747043f6f7e0870cc5aa72c146dfae9543c5ba8/tokio/tests/sync_rwlock.rs
1
60
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:4
assert_pending!(t4.poll()); } // when there is an active shared owner, and exclusive access is triggered, // reading should be possible after pending exclusive access is dropped #[test] fn write_read_shared_drop_pending() { let rwlock = RwLock::new(100); let mut t1 = spawn(rwlock.read()); let _g1 = assert_...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
2747043f6f7e0870cc5aa72c146dfae9543c5ba8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2747043f6f7e0870cc5aa72c146dfae9543c5ba8/tokio/tests/sync_rwlock.rs
121
180
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:5
// RwLocks should be acquired in the order that their Futures are waited upon. #[maybe_tokio_test] async fn write_order() { let rwlock = RwLock::<Vec<u32>>::new(vec![]); let fut2 = rwlock.write().map(|mut guard| guard.push(2)); let fut1 = rwlock.write().map(|mut guard| guard.push(1)); fut1.await; fu...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
2747043f6f7e0870cc5aa72c146dfae9543c5ba8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2747043f6f7e0870cc5aa72c146dfae9543c5ba8/tokio/tests/sync_rwlock.rs
161
220
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:1
#![warn(rust_2018_idioms)] use std::sync::Arc; use std::task::Poll; use futures::future::FutureExt; use futures::stream; use futures::stream::StreamExt; use tokio::sync::{Barrier, RwLock}; use tokio_test::task::spawn; use tokio_test::{assert_pending, assert_ready}; #[test] fn into_inner() { let rwlock = RwLock:...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
08ed41f339e345286f26bdbc6c67bf9f2975ed07
github
async-runtime
https://github.com/tokio-rs/tokio/blob/08ed41f339e345286f26bdbc6c67bf9f2975ed07/tokio/tests/sync_rwlock.rs
1
60
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:2
// When there is an active exclusive owner, subsequent exclusive access should not be possible #[test] fn read_exclusive_pending() { let rwlock = RwLock::new(100); let mut t1 = spawn(rwlock.write()); let _g1 = assert_ready!(t1.poll()); let mut t2 = spawn(rwlock.read()); assert_pending!(t2.poll()); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
08ed41f339e345286f26bdbc6c67bf9f2975ed07
github
async-runtime
https://github.com/tokio-rs/tokio/blob/08ed41f339e345286f26bdbc6c67bf9f2975ed07/tokio/tests/sync_rwlock.rs
41
100
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:3
let _g1 = assert_ready!(t1.poll()); let mut t2 = spawn(rwlock.write()); assert_pending!(t2.poll()); } // When there is an active shared owner, exclusive access should be possible after shared is dropped #[test] fn write_shared_drop() { let rwlock = RwLock::new(100); let mut t1 = spawn(rwlock.read()); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
08ed41f339e345286f26bdbc6c67bf9f2975ed07
github
async-runtime
https://github.com/tokio-rs/tokio/blob/08ed41f339e345286f26bdbc6c67bf9f2975ed07/tokio/tests/sync_rwlock.rs
81
140
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:4
fn write_read_shared_drop_pending() { let rwlock = RwLock::new(100); let mut t1 = spawn(rwlock.read()); let _g1 = assert_ready!(t1.poll()); let mut t2 = spawn(rwlock.write()); assert_pending!(t2.poll()); let mut t3 = spawn(rwlock.read()); assert_pending!(t3.poll()); drop(t2); asse...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
08ed41f339e345286f26bdbc6c67bf9f2975ed07
github
async-runtime
https://github.com/tokio-rs/tokio/blob/08ed41f339e345286f26bdbc6c67bf9f2975ed07/tokio/tests/sync_rwlock.rs
121
180
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:5
fut1.await; fut2.await; let g = rwlock.read().await; assert_eq!(*g, vec![1, 2]); } // A single RwLock is contested by tasks in multiple threads #[tokio::test(flavor = "multi_thread", worker_threads = 8)] async fn multithreaded() { let barrier = Arc::new(Barrier::new(5)); let rwlock = Arc::new(RwLo...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
08ed41f339e345286f26bdbc6c67bf9f2975ed07
github
async-runtime
https://github.com/tokio-rs/tokio/blob/08ed41f339e345286f26bdbc6c67bf9f2975ed07/tokio/tests/sync_rwlock.rs
161
220
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:6
}) .await; b2.wait().await; }); let b3 = barrier.clone(); tokio::spawn(async move { stream::iter(0..1000) .for_each(move |_| { let rwlock = rwclone3.clone(); async move { let mut guard = rwlock.write().await; ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
08ed41f339e345286f26bdbc6c67bf9f2975ed07
github
async-runtime
https://github.com/tokio-rs/tokio/blob/08ed41f339e345286f26bdbc6c67bf9f2975ed07/tokio/tests/sync_rwlock.rs
201
260
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:7
let lock = RwLock::new(0); let read_guard = lock.read().await; assert!(lock.try_write().is_err()); drop(read_guard); assert!(lock.try_write().is_ok()); } #[test] fn try_read_try_write() { let lock: RwLock<usize> = RwLock::new(15); { let rg1 = lock.try_read().unwrap(); assert_eq...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
08ed41f339e345286f26bdbc6c67bf9f2975ed07
github
async-runtime
https://github.com/tokio-rs/tokio/blob/08ed41f339e345286f26bdbc6c67bf9f2975ed07/tokio/tests/sync_rwlock.rs
241
270
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:1
#![warn(rust_2018_idioms)] use std::sync::Arc; use std::task::Poll; use futures::future::FutureExt; use futures::stream; use futures::stream::StreamExt; use tokio::sync::{Barrier, RwLock}; use tokio_test::task::spawn; use tokio_test::{assert_pending, assert_ready}; #[test] fn into_inner() { let rwlock = RwLock:...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
a5ee2f0d3d78daa01e2c6c12d22b82474dc5c32a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a5ee2f0d3d78daa01e2c6c12d22b82474dc5c32a/tokio/tests/sync_rwlock.rs
1
60
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:2
// When there is an active exclusive owner, subsequent exclusive access should not be possible #[test] fn read_exclusive_pending() { let rwlock = RwLock::new(100); let mut t1 = spawn(rwlock.write()); let _g1 = assert_ready!(t1.poll()); let mut t2 = spawn(rwlock.read()); assert_pending!(t2.poll()); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
a5ee2f0d3d78daa01e2c6c12d22b82474dc5c32a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a5ee2f0d3d78daa01e2c6c12d22b82474dc5c32a/tokio/tests/sync_rwlock.rs
41
100
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:1
#![warn(rust_2018_idioms)] use std::sync::Arc; use std::task::Poll; use futures::future::FutureExt; use futures::stream; use futures::stream::StreamExt; use tokio::sync::{Barrier, RwLock}; use tokio_test::task::spawn; use tokio_test::{assert_pending, assert_ready}; #[test] fn into_inner() { let rwlock = RwLock:...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
e89c8981f151a667bb676213d38b7dbeb51620e9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e89c8981f151a667bb676213d38b7dbeb51620e9/tokio/tests/sync_rwlock.rs
1
60
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:2
// When there is an active exclusive owner, subsequent exclusive access should not be possible #[test] fn read_exclusive_pending() { let rwlock = RwLock::new(100); let mut t1 = spawn(rwlock.write()); let _g1 = assert_ready!(t1.poll()); let mut t2 = spawn(rwlock.read()); assert_pending!(t2.poll()); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
e89c8981f151a667bb676213d38b7dbeb51620e9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e89c8981f151a667bb676213d38b7dbeb51620e9/tokio/tests/sync_rwlock.rs
41
100
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:1
#![warn(rust_2018_idioms)] use std::sync::Arc; use std::task::Poll; use futures::future::FutureExt; use futures::stream; use futures::stream::StreamExt; use tokio::sync::{Barrier, RwLock}; use tokio_test::task::spawn; use tokio_test::{assert_pending, assert_ready}; #[test] fn into_inner() { let rwlock = RwLock:...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
ecc32d1dca2317e555d8a6b29009cf19ef8f53e8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ecc32d1dca2317e555d8a6b29009cf19ef8f53e8/tokio/tests/sync_rwlock.rs
1
60
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:2
// When there is an active exclusive owner, subsequent exclusive access should not be possible #[test] fn read_exclusive_pending() { let rwlock = RwLock::new(100); let mut t1 = spawn(rwlock.write()); let _g1 = assert_ready!(t1.poll()); let mut t2 = spawn(rwlock.read()); assert_pending!(t2.poll()); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
ecc32d1dca2317e555d8a6b29009cf19ef8f53e8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ecc32d1dca2317e555d8a6b29009cf19ef8f53e8/tokio/tests/sync_rwlock.rs
41
100
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:6
}) .await; b2.wait().await; }); let b3 = barrier.clone(); tokio::spawn(async move { stream::iter(0..1000) .for_each(move |_| { let rwlock = rwclone3.clone(); async move { let mut guard = rwlock.write().await; ...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/tests/sync_rwlock.rs
201
237
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:4
fn write_read_shared_drop_pending() { let rwlock = RwLock::new(100); let mut t1 = spawn(rwlock.read()); let _g1 = assert_ready!(t1.poll()); let mut t2 = spawn(rwlock.write()); assert_pending!(t2.poll()); let mut t3 = spawn(rwlock.read()); assert_pending!(t3.poll()); drop(t2); asse...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
c3b830110aa3f13346721dc148e074c122c7ddbe
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c3b830110aa3f13346721dc148e074c122c7ddbe/tokio/tests/sync_rwlock.rs
121
180
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:5
fut1.await; fut2.await; let g = rwlock.read().await; assert_eq!(*g, vec![1, 2]); } // A single RwLock is contested by tasks in multiple threads #[tokio::test(threaded_scheduler)] async fn multithreaded() { let barrier = Arc::new(Barrier::new(5)); let rwlock = Arc::new(RwLock::<u32>::new(0)); l...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
c3b830110aa3f13346721dc148e074c122c7ddbe
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c3b830110aa3f13346721dc148e074c122c7ddbe/tokio/tests/sync_rwlock.rs
161
220
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:1
#![warn(rust_2018_idioms)] use std::sync::Arc; use std::task::Poll; use futures::future::FutureExt; use futures::stream; use futures::stream::StreamExt; use tokio::sync::{Barrier, RwLock}; use tokio_test::task::spawn; use tokio_test::{assert_pending, assert_ready}; // multiple reads should be Ready #[test] fn read_...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
bd8971cd95b2c182c16d8bfc5ee43754ee4e9c96
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bd8971cd95b2c182c16d8bfc5ee43754ee4e9c96/tokio/tests/sync_rwlock.rs
1
60
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:2
let _g1 = assert_ready!(t1.poll()); let mut t2 = spawn(rwlock.read()); assert_pending!(t2.poll()); } // If the max shared access is reached and subsquent shared access is pending // should be made available when one of the shared acesses is dropped #[test] fn exhaust_reading() { let rwlock = RwLock::new(10...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
bd8971cd95b2c182c16d8bfc5ee43754ee4e9c96
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bd8971cd95b2c182c16d8bfc5ee43754ee4e9c96/tokio/tests/sync_rwlock.rs
41
100
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:3
#[test] fn write_shared_drop() { let rwlock = RwLock::new(100); let mut t1 = spawn(rwlock.read()); let g1 = assert_ready!(t1.poll()); let mut t2 = spawn(rwlock.write()); assert_pending!(t2.poll()); drop(g1); assert!(t2.is_woken()); assert_ready!(t2.poll()); } // when there is an active...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
bd8971cd95b2c182c16d8bfc5ee43754ee4e9c96
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bd8971cd95b2c182c16d8bfc5ee43754ee4e9c96/tokio/tests/sync_rwlock.rs
81
140
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:4
assert_pending!(t2.poll()); let mut t3 = spawn(rwlock.read()); assert_pending!(t3.poll()); drop(t2); assert!(t3.is_woken()); assert_ready!(t3.poll()); } // Acquire an RwLock nonexclusively by a single task #[tokio::test] async fn read_uncontested() { let rwlock = RwLock::new(100); let res...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
bd8971cd95b2c182c16d8bfc5ee43754ee4e9c96
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bd8971cd95b2c182c16d8bfc5ee43754ee4e9c96/tokio/tests/sync_rwlock.rs
121
180
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:5
// A single RwLock is contested by tasks in multiple threads #[tokio::test(threaded_scheduler)] async fn multithreaded() { let barrier = Arc::new(Barrier::new(5)); let rwlock = Arc::new(RwLock::<u32>::new(0)); let rwclone1 = rwlock.clone(); let rwclone2 = rwlock.clone(); let rwclone3 = rwlock.clone(...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
bd8971cd95b2c182c16d8bfc5ee43754ee4e9c96
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bd8971cd95b2c182c16d8bfc5ee43754ee4e9c96/tokio/tests/sync_rwlock.rs
161
220
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:6
tokio::spawn(async move { stream::iter(0..1000) .for_each(move |_| { let rwlock = rwclone3.clone(); async move { let mut guard = rwlock.write().await; *guard += 5; } }) .await; b3....
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
bd8971cd95b2c182c16d8bfc5ee43754ee4e9c96
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bd8971cd95b2c182c16d8bfc5ee43754ee4e9c96/tokio/tests/sync_rwlock.rs
201
231
tokio-rs/tokio:tokio/tests/sync_rwlock.rs:3
#[test] fn write_shared_drop() { let rwlock = RwLock::new(100); let mut t1 = spawn(rwlock.read()); let g1 = assert_ready!(t1.poll()); let mut t2 = spawn(rwlock.write()); assert_pending!(t2.poll()); drop(g1); assert!(t2.is_woken()); assert_ready!(t2.poll()); } // when there is an active...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_rwlock.rs
MIT
32e15b3a24ac177c92a78eb04e233534583eae17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/32e15b3a24ac177c92a78eb04e233534583eae17/tokio/tests/sync_rwlock.rs
81
140
tokio-rs/tokio:tokio/tests/sync_semaphore.rs:1
#![cfg(feature = "sync")] #[cfg(all(target_family = "wasm", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as test; use std::sync::Arc; use tokio::sync::Semaphore; #[test] fn no_permits() { // this should not panic Semaphore::new(0); } #[test] fn try_acquire() { let sem = Semaphore:...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_semaphore.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_semaphore.rs
1
60
tokio-rs/tokio:tokio/tests/sync_semaphore.rs:2
#[tokio::test] #[cfg(feature = "full")] async fn add_permits() { let sem = Arc::new(Semaphore::new(0)); let sem_clone = sem.clone(); let j = tokio::spawn(async move { let _p2 = sem_clone.acquire().await; }); sem.add_permits(1); j.await.unwrap(); } #[test] fn add_permits_open() { for...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_semaphore.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_semaphore.rs
41
100
tokio-rs/tokio:tokio/tests/sync_semaphore.rs:3
{ let p = sem.try_acquire().unwrap(); assert_eq!(sem.available_permits(), 0); p.forget(); assert_eq!(sem.available_permits(), 0); } assert_eq!(sem.available_permits(), 0); assert!(sem.try_acquire().is_err()); } #[test] fn forget_open() { for size in 0..4 { for su...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_semaphore.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_semaphore.rs
81
140
tokio-rs/tokio:tokio/tests/sync_semaphore.rs:4
fn merge() { let sem = Arc::new(Semaphore::new(3)); { let mut p1 = sem.try_acquire().unwrap(); assert_eq!(sem.available_permits(), 2); let p2 = sem.try_acquire_many(2).unwrap(); assert_eq!(sem.available_permits(), 0); p1.merge(p2); assert_eq!(sem.available_permits...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_semaphore.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_semaphore.rs
121
180
tokio-rs/tokio:tokio/tests/sync_semaphore.rs:5
assert_eq!(p4.num_permits(), 1); assert!(p2.split(1).is_none()); drop(p2); assert_eq!(sem.available_permits(), 4); drop(p3); assert_eq!(sem.available_permits(), 4); drop(p4); assert_eq!(sem.available_permits(), 5); } #[tokio::test] #[cfg(feature = "full")] async fn stress_test() { let s...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_semaphore.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_semaphore.rs
161
220
tokio-rs/tokio:tokio/tests/sync_semaphore.rs:6
#[cfg(not(target_family = "wasm"))] // wasm currently doesn't support unwinding #[test] #[should_panic] fn add_more_than_max_amount_permits1() { let s = tokio::sync::Semaphore::new(1); s.add_permits(tokio::sync::Semaphore::MAX_PERMITS); } #[cfg(not(target_family = "wasm"))] // wasm currently doesn't support un...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_semaphore.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/tests/sync_semaphore.rs
201
230
tokio-rs/tokio:tokio/tests/sync_semaphore.rs:1
#![cfg(feature = "sync")] #[cfg(all(target_family = "wasm", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as test; use std::sync::Arc; use tokio::sync::Semaphore; #[test] fn no_permits() { // this should not panic Semaphore::new(0); } #[test] fn try_acquire() { let sem = Semaphore:...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_semaphore.rs
MIT
224fea4f3ca116f1fb416da5acc36faa8e3e8b5d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/224fea4f3ca116f1fb416da5acc36faa8e3e8b5d/tokio/tests/sync_semaphore.rs
1
60
tokio-rs/tokio:tokio/tests/sync_semaphore.rs:2
#[tokio::test] #[cfg(feature = "full")] async fn add_permits() { let sem = Arc::new(Semaphore::new(0)); let sem_clone = sem.clone(); let j = tokio::spawn(async move { let _p2 = sem_clone.acquire().await; }); sem.add_permits(1); j.await.unwrap(); } #[test] fn forget() { let sem = Arc...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_semaphore.rs
MIT
224fea4f3ca116f1fb416da5acc36faa8e3e8b5d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/224fea4f3ca116f1fb416da5acc36faa8e3e8b5d/tokio/tests/sync_semaphore.rs
41
100
tokio-rs/tokio:tokio/tests/sync_semaphore.rs:3
#[cfg(not(target_family = "wasm"))] // No stack unwinding on wasm targets #[should_panic] fn merge_unrelated_permits() { let sem1 = Arc::new(Semaphore::new(3)); let sem2 = Arc::new(Semaphore::new(3)); let mut p1 = sem1.try_acquire().unwrap(); let p2 = sem2.try_acquire().unwrap(); p1.merge(p2); } #[...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_semaphore.rs
MIT
224fea4f3ca116f1fb416da5acc36faa8e3e8b5d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/224fea4f3ca116f1fb416da5acc36faa8e3e8b5d/tokio/tests/sync_semaphore.rs
81
140
tokio-rs/tokio:tokio/tests/sync_semaphore.rs:4
let mut join_handles = Vec::new(); for _ in 0..1000 { let sem_clone = sem.clone(); join_handles.push(tokio::spawn(async move { let _p = sem_clone.acquire().await; })); } for j in join_handles { j.await.unwrap(); } // there should be exactly 5 semaphores av...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_semaphore.rs
MIT
224fea4f3ca116f1fb416da5acc36faa8e3e8b5d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/224fea4f3ca116f1fb416da5acc36faa8e3e8b5d/tokio/tests/sync_semaphore.rs
121
176
tokio-rs/tokio:tokio/tests/sync_semaphore.rs:5
s.add_permits(1); } #[cfg(not(target_family = "wasm"))] // wasm currently doesn't support unwinding #[test] #[should_panic] fn panic_when_exceeds_maxpermits() { let _ = Semaphore::new(Semaphore::MAX_PERMITS + 1); } #[test] fn no_panic_at_maxpermits() { let _ = Semaphore::new(Semaphore::MAX_PERMITS); let s...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_semaphore.rs
MIT
224fea4f3ca116f1fb416da5acc36faa8e3e8b5d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/224fea4f3ca116f1fb416da5acc36faa8e3e8b5d/tokio/tests/sync_semaphore.rs
161
176
tokio-rs/tokio:tokio/tests/sync_semaphore.rs:2
#[tokio::test] #[cfg(feature = "full")] async fn add_permits() { let sem = Arc::new(Semaphore::new(0)); let sem_clone = sem.clone(); let j = tokio::spawn(async move { let _p2 = sem_clone.acquire().await; }); sem.add_permits(1); j.await.unwrap(); } #[test] fn forget() { let sem = Arc...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_semaphore.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/sync_semaphore.rs
41
100
tokio-rs/tokio:tokio/tests/sync_semaphore.rs:3
#[cfg(not(target_family = "wasm"))] // No stack unwinding on wasm targets #[should_panic] fn merge_unrelated_permits() { let sem1 = Arc::new(Semaphore::new(3)); let sem2 = Arc::new(Semaphore::new(3)); let mut p1 = sem1.try_acquire().unwrap(); let p2 = sem2.try_acquire().unwrap(); p1.merge(p2); } #[...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_semaphore.rs
MIT
c445e467ce4363b3a9b6825268814a9bc27c0127
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/tests/sync_semaphore.rs
81
140
tokio-rs/tokio:tokio/tests/sync_semaphore.rs:1
#![cfg(feature = "sync")] #[cfg(tokio_wasm_not_wasi)] use wasm_bindgen_test::wasm_bindgen_test as test; use std::sync::Arc; use tokio::sync::Semaphore; #[test] fn no_permits() { // this should not panic Semaphore::new(0); } #[test] fn try_acquire() { let sem = Semaphore::new(1); { let p1 = s...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_semaphore.rs
MIT
d1a8ec6495701e47b9ce34ddf6fa4baca1597290
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d1a8ec6495701e47b9ce34ddf6fa4baca1597290/tokio/tests/sync_semaphore.rs
1
60
tokio-rs/tokio:tokio/tests/sync_semaphore.rs:2
#[tokio::test] #[cfg(feature = "full")] async fn add_permits() { let sem = Arc::new(Semaphore::new(0)); let sem_clone = sem.clone(); let j = tokio::spawn(async move { let _p2 = sem_clone.acquire().await; }); sem.add_permits(1); j.await.unwrap(); } #[test] fn forget() { let sem = Arc...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_semaphore.rs
MIT
d1a8ec6495701e47b9ce34ddf6fa4baca1597290
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d1a8ec6495701e47b9ce34ddf6fa4baca1597290/tokio/tests/sync_semaphore.rs
41
100
tokio-rs/tokio:tokio/tests/sync_semaphore.rs:3
#[cfg(not(tokio_wasm))] // No stack unwinding on wasm targets #[should_panic] fn merge_unrelated_permits() { let sem1 = Arc::new(Semaphore::new(3)); let sem2 = Arc::new(Semaphore::new(3)); let mut p1 = sem1.try_acquire().unwrap(); let p2 = sem2.try_acquire().unwrap(); p1.merge(p2); } #[tokio::test]...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_semaphore.rs
MIT
d1a8ec6495701e47b9ce34ddf6fa4baca1597290
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d1a8ec6495701e47b9ce34ddf6fa4baca1597290/tokio/tests/sync_semaphore.rs
81
140
tokio-rs/tokio:tokio/tests/sync_semaphore.rs:4
#[cfg(not(tokio_wasm))] // wasm currently doesn't support unwinding #[test] #[should_panic] fn add_more_than_max_amount_permits1() { let s = tokio::sync::Semaphore::new(1); s.add_permits(tokio::sync::Semaphore::MAX_PERMITS); } #[cfg(not(tokio_wasm))] // wasm currently doesn't support unwinding #[test] #[should...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_semaphore.rs
MIT
d1a8ec6495701e47b9ce34ddf6fa4baca1597290
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d1a8ec6495701e47b9ce34ddf6fa4baca1597290/tokio/tests/sync_semaphore.rs
121
150
tokio-rs/tokio:tokio/tests/sync_semaphore.rs:3
#[cfg(not(tokio_wasm))] // No stack unwinding on wasm targets #[should_panic] fn merge_unrelated_permits() { let sem1 = Arc::new(Semaphore::new(3)); let sem2 = Arc::new(Semaphore::new(3)); let mut p1 = sem1.try_acquire().unwrap(); let p2 = sem2.try_acquire().unwrap(); p1.merge(p2); } #[tokio::test]...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_semaphore.rs
MIT
909de088450a31d1c472adc44532dca4910765b2
github
async-runtime
https://github.com/tokio-rs/tokio/blob/909de088450a31d1c472adc44532dca4910765b2/tokio/tests/sync_semaphore.rs
81
127
tokio-rs/tokio:tokio/tests/sync_semaphore.rs:2
#[tokio::test] #[cfg(feature = "full")] async fn add_permits() { let sem = Arc::new(Semaphore::new(0)); let sem_clone = sem.clone(); let j = tokio::spawn(async move { let _p2 = sem_clone.acquire().await; }); sem.add_permits(1); j.await.unwrap(); } #[test] fn forget() { let sem = Arc...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_semaphore.rs
MIT
b2ada60e701d5c9e6644cf8fc42a100774f8e23f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/sync_semaphore.rs
41
100
tokio-rs/tokio:tokio/tests/sync_semaphore.rs:3
let _p1 = sem.try_acquire().unwrap(); let _p2 = sem.try_acquire().unwrap(); let _p3 = sem.try_acquire().unwrap(); let _p4 = sem.try_acquire().unwrap(); let _p5 = sem.try_acquire().unwrap(); assert!(sem.try_acquire().is_err()); } #[test] fn add_max_amount_permits() { let s = tokio::sync::Semapho...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_semaphore.rs
MIT
b2ada60e701d5c9e6644cf8fc42a100774f8e23f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/tests/sync_semaphore.rs
81
102
tokio-rs/tokio:tokio/tests/sync_semaphore.rs:2
#[tokio::test] #[cfg(feature = "full")] async fn add_permits() { let sem = Arc::new(Semaphore::new(0)); let sem_clone = sem.clone(); let j = tokio::spawn(async move { let _p2 = sem_clone.acquire().await; }); sem.add_permits(1); j.await.unwrap(); } #[test] fn forget() { let sem = Arc...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_semaphore.rs
MIT
0dc62da21b0bffe113e2efa23f6da6ef4e36bf4f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0dc62da21b0bffe113e2efa23f6da6ef4e36bf4f/tokio/tests/sync_semaphore.rs
41
100
tokio-rs/tokio:tokio/tests/sync_semaphore.rs:3
let _p1 = sem.try_acquire().unwrap(); let _p2 = sem.try_acquire().unwrap(); let _p3 = sem.try_acquire().unwrap(); let _p4 = sem.try_acquire().unwrap(); let _p5 = sem.try_acquire().unwrap(); assert!(sem.try_acquire().is_err()); } #[test] fn add_max_amount_permits() { let s = tokio::sync::Semapho...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_semaphore.rs
MIT
0dc62da21b0bffe113e2efa23f6da6ef4e36bf4f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0dc62da21b0bffe113e2efa23f6da6ef4e36bf4f/tokio/tests/sync_semaphore.rs
81
102
tokio-rs/tokio:tokio/tests/sync_semaphore.rs:1
#![cfg(feature = "sync")] #[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use wasm_bindgen_test::wasm_bindgen_test as test; use std::sync::Arc; use tokio::sync::Semaphore; #[test] fn no_permits() { // this should not panic Semaphore::new(0); } #[test] fn try_acquire() { let sem = Semaphore:...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_semaphore.rs
MIT
f3e340a35b306e926e78537a0dd65b2e9b9cdc89
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3e340a35b306e926e78537a0dd65b2e9b9cdc89/tokio/tests/sync_semaphore.rs
1
60
tokio-rs/tokio:tokio/tests/sync_semaphore.rs:2
#[tokio::test] #[cfg(feature = "full")] async fn add_permits() { let sem = Arc::new(Semaphore::new(0)); let sem_clone = sem.clone(); let j = tokio::spawn(async move { let _p2 = sem_clone.acquire().await; }); sem.add_permits(1); j.await.unwrap(); } #[test] fn forget() { let sem = Arc...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_semaphore.rs
MIT
f3e340a35b306e926e78537a0dd65b2e9b9cdc89
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3e340a35b306e926e78537a0dd65b2e9b9cdc89/tokio/tests/sync_semaphore.rs
41
100
tokio-rs/tokio:tokio/tests/sync_semaphore.rs:3
let _p1 = sem.try_acquire().unwrap(); let _p2 = sem.try_acquire().unwrap(); let _p3 = sem.try_acquire().unwrap(); let _p4 = sem.try_acquire().unwrap(); let _p5 = sem.try_acquire().unwrap(); assert!(sem.try_acquire().is_err()); } #[test] fn add_max_amount_permits() { let s = tokio::sync::Semapho...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_semaphore.rs
MIT
f3e340a35b306e926e78537a0dd65b2e9b9cdc89
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f3e340a35b306e926e78537a0dd65b2e9b9cdc89/tokio/tests/sync_semaphore.rs
81
102
tokio-rs/tokio:tokio/tests/sync_semaphore.rs:2
#[tokio::test] #[cfg(feature = "full")] async fn add_permits() { let sem = Arc::new(Semaphore::new(0)); let sem_clone = sem.clone(); let j = tokio::spawn(async move { let _p2 = sem_clone.acquire().await; }); sem.add_permits(1); j.await.unwrap(); } #[test] fn forget() { let sem = Arc...
rust
rust
testsuite
tokio-rs/tokio
tokio/tests/sync_semaphore.rs
MIT
6d3f92dddc510e9276191cfab1b0432ce8248589
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/tests/sync_semaphore.rs
41
100