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/src/sync/tests/loom_oneshot.rs:2 | if ready {
None
} else {
Some(rx)
}
})
.join()
.unwrap();
if let Some(rx) = rx {
// Previous task parked, use a new task...
let value = block_on(rx).unwrap();
assert_eq!(1, value);
}
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_oneshot.rs | MIT | 8a7e57786a5dca139f5b4261685e22991ded0859 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/sync/tests/loom_oneshot.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/tests/loom_oneshot.rs:3 | }
#[test]
fn changing_tx_task() {
loom::model(|| {
let (mut tx, rx) = oneshot::channel::<i32>();
thread::spawn(move || {
drop(rx);
});
let tx = thread::spawn(move || {
let t1 = block_on(OnClose::new(&mut tx));
if t1 {
None
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_oneshot.rs | MIT | 8a7e57786a5dca139f5b4261685e22991ded0859 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/sync/tests/loom_oneshot.rs | 81 | 109 |
tokio-rs/tokio:tokio/src/sync/tests/loom_rwlock.rs:1 | use crate::sync::rwlock::*;
use loom::future::block_on;
use loom::thread;
use std::sync::Arc;
#[test]
fn concurrent_write() {
let b = loom::model::Builder::new();
b.check(|| {
let rwlock = Arc::new(RwLock::<u32>::new(0));
let rwclone = rwlock.clone();
let t1 = thread::spawn(move || {... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_rwlock.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/tests/loom_rwlock.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/tests/loom_rwlock.rs:2 | b.check(|| {
let rwlock = Arc::new(RwLock::<u32>::new(0));
let rwclone = rwlock.clone();
let t1 = thread::spawn(move || {
block_on(async {
let mut guard = rwclone.write().await;
*guard += 5;
});
});
let rwclone = rwlock.cl... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_rwlock.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/tests/loom_rwlock.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/tests/loom_rwlock.rs:3 | //when all threads have finished the value on the lock should be 10
assert_eq!(10, *guard);
});
}
#[test]
fn downgrade() {
loom::model(|| {
let lock = Arc::new(RwLock::new(1));
let n = block_on(lock.write());
let cloned_lock = lock.clone();
let handle = thread::spawn(mo... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_rwlock.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/tests/loom_rwlock.rs | 81 | 105 |
tokio-rs/tokio:tokio/src/sync/tests/loom_rwlock.rs:1 | use crate::sync::rwlock::*;
use loom::future::block_on;
use loom::thread;
use std::sync::Arc;
#[test]
fn concurrent_write() {
let b = loom::model::Builder::new();
b.check(|| {
let rwlock = Arc::new(RwLock::<u32>::new(0));
let rwclone = rwlock.clone();
let t1 = thread::spawn(move || {... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_rwlock.rs | MIT | e804f88d60071f0d89db85aaa4a073857904b545 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e804f88d60071f0d89db85aaa4a073857904b545/tokio/src/sync/tests/loom_rwlock.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/tests/loom_rwlock.rs:2 | b.check(|| {
let rwlock = Arc::new(RwLock::<u32>::new(0));
let rwclone = rwlock.clone();
let t1 = thread::spawn(move || {
block_on(async {
let mut guard = rwclone.write().await;
*guard += 5;
});
});
let rwclone = rwlock.cl... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_rwlock.rs | MIT | e804f88d60071f0d89db85aaa4a073857904b545 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e804f88d60071f0d89db85aaa4a073857904b545/tokio/src/sync/tests/loom_rwlock.rs | 41 | 99 |
tokio-rs/tokio:tokio/src/sync/tests/loom_rwlock.rs:3 | loom::model(|| {
let lock = Arc::new(RwLock::new(1));
let n = block_on(lock.write());
let cloned_lock = lock.clone();
let handle = thread::spawn(move || {
let mut guard = block_on(cloned_lock.write());
*guard = 2;
});
let n = n.downgrade();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_rwlock.rs | MIT | e804f88d60071f0d89db85aaa4a073857904b545 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e804f88d60071f0d89db85aaa4a073857904b545/tokio/src/sync/tests/loom_rwlock.rs | 81 | 99 |
tokio-rs/tokio:tokio/src/sync/tests/loom_rwlock.rs:1 | use crate::sync::rwlock::*;
use loom::future::block_on;
use loom::thread;
use std::sync::Arc;
#[test]
fn concurrent_write() {
let mut b = loom::model::Builder::new();
b.check(|| {
let rwlock = Arc::new(RwLock::<u32>::new(0));
let rwclone = rwlock.clone();
let t1 = thread::spawn(move ... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_rwlock.rs | MIT | 32e15b3a24ac177c92a78eb04e233534583eae17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/32e15b3a24ac177c92a78eb04e233534583eae17/tokio/src/sync/tests/loom_rwlock.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/tests/loom_rwlock.rs:2 | b.check(|| {
let rwlock = Arc::new(RwLock::<u32>::new(0));
let rwclone = rwlock.clone();
let t1 = thread::spawn(move || {
block_on(async {
let mut guard = rwclone.write().await;
*guard += 5;
});
});
let rwclone = rwlock.cl... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_rwlock.rs | MIT | 32e15b3a24ac177c92a78eb04e233534583eae17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/32e15b3a24ac177c92a78eb04e233534583eae17/tokio/src/sync/tests/loom_rwlock.rs | 41 | 78 |
tokio-rs/tokio:tokio/src/sync/tests/loom_semaphore.rs:1 | use crate::sync::semaphore::*;
use futures::future::poll_fn;
use loom::future::block_on;
use loom::thread;
use std::future::Future;
use std::pin::Pin;
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering::SeqCst;
use std::sync::Arc;
use std::task::Poll::Ready;
use std::task::{Context, Poll};
#[test]
fn... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_semaphore.rs | MIT | 8a7e57786a5dca139f5b4261685e22991ded0859 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/sync/tests/loom_semaphore.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/tests/loom_semaphore.rs:2 | me.waiter.release(&me.shared.semaphore);
Ready(())
}
}
loom::model(|| {
let shared = Arc::new(Shared {
semaphore: Semaphore::new(NUM),
active: AtomicUsize::new(0),
});
for _ in 0..NUM {
let shared = shared.clone();
t... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_semaphore.rs | MIT | 8a7e57786a5dca139f5b4261685e22991ded0859 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/sync/tests/loom_semaphore.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/tests/loom_semaphore.rs:3 | block_on(poll_fn(|cx| permit.poll_acquire(cx, &semaphore))).unwrap();
permit.release(&semaphore);
});
}
let mut permit = Permit::new();
block_on(poll_fn(|cx| permit.poll_acquire(cx, &semaphore))).unwrap();
permit.release(&semaphore);
});
}
#[test]
fn ... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_semaphore.rs | MIT | 8a7e57786a5dca139f5b4261685e22991ded0859 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/sync/tests/loom_semaphore.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/tests/loom_semaphore.rs:4 | semaphore.close();
});
}
#[test]
fn concurrent_close() {
const NUM: usize = 3;
loom::model(|| {
let semaphore = Arc::new(Semaphore::new(1));
for _ in 0..NUM {
let semaphore = semaphore.clone();
thread::spawn(move || {
let mut permit = Permit::new()... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_semaphore.rs | MIT | 8a7e57786a5dca139f5b4261685e22991ded0859 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/sync/tests/loom_semaphore.rs | 121 | 150 |
tokio-rs/tokio:tokio/src/sync/tests/loom_semaphore_batch.rs:1 | use crate::sync::batch_semaphore::*;
use loom::future::block_on;
use loom::sync::atomic::AtomicUsize;
use loom::thread;
use std::future::{poll_fn, Future};
use std::pin::Pin;
use std::sync::atomic::Ordering::SeqCst;
use std::sync::Arc;
use std::task::Poll::Ready;
use std::task::{Context, Poll};
#[test]
fn basic_usage... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_semaphore_batch.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/tests/loom_semaphore_batch.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/tests/loom_semaphore_batch.rs:2 | thread::spawn(move || {
block_on(actor(shared));
});
}
block_on(actor(shared));
});
}
#[test]
fn release() {
loom::model(|| {
let semaphore = Arc::new(Semaphore::new(1));
{
let semaphore = semaphore.clone();
thread::spawn(mov... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_semaphore_batch.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/tests/loom_semaphore_batch.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/tests/loom_semaphore_batch.rs:3 | block_on(semaphore.acquire(1)).map_err(|_| ())?;
semaphore.release(1);
}
Ok::<(), ()>(())
});
}
semaphore.close();
});
}
#[test]
fn concurrent_close() {
const NUM: usize = 3;
loom::model(|| {
let semaphore = Arc::ne... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_semaphore_batch.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/tests/loom_semaphore_batch.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/tests/loom_semaphore_batch.rs:4 | // poll the acquire future once, and then immediately throw
// it away. this simulates a situation where a future is
// polled and then cancelled, such as by a timeout.
if let Some(acquire) = acquire1.take() {
pin!(acquire);
let _ = acquire.poll(cx);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_semaphore_batch.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/tests/loom_semaphore_batch.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/tests/loom_semaphore_batch.rs:5 | let mut b = loom::model::Builder::new();
b.preemption_bound = Some(1);
b.check(|| {
let semaphore = Arc::new(Semaphore::new(10));
let active = Arc::new(AtomicUsize::new(0));
let mut threads = vec![];
for _ in 0..2 {
let semaphore = semaphore.clone();
let... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_semaphore_batch.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/tests/loom_semaphore_batch.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/tests/loom_semaphore_batch.rs:6 | loom::model(|| {
let semaphore = Arc::new(Semaphore::new(10));
semaphore
.try_acquire(8)
.expect("try_acquire should succeed; semaphore uncontended");
let semaphore2 = semaphore.clone();
let thread = thread::spawn(move || block_on(semaphore2.acquire(4)).unwrap());... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_semaphore_batch.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/tests/loom_semaphore_batch.rs | 201 | 242 |
tokio-rs/tokio:tokio/src/sync/tests/loom_semaphore_batch.rs:4 | // poll the acquire future once, and then immediately throw
// it away. this simulates a situation where a future is
// polled and then cancelled, such as by a timeout.
if let Some(acquire) = acquire1.take() {
pin!(acquire);
let _ = acquire.poll(cx);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_semaphore_batch.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/sync/tests/loom_semaphore_batch.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/tests/loom_semaphore_batch.rs:5 | let mut b = loom::model::Builder::new();
b.preemption_bound = Some(1);
b.check(|| {
let semaphore = Arc::new(Semaphore::new(10));
let active = Arc::new(AtomicUsize::new(0));
let mut ths = vec![];
for _ in 0..2 {
let semaphore = semaphore.clone();
let act... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_semaphore_batch.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/sync/tests/loom_semaphore_batch.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/tests/loom_semaphore_batch.rs:1 | use crate::sync::batch_semaphore::*;
use futures::future::poll_fn;
use loom::future::block_on;
use loom::sync::atomic::AtomicUsize;
use loom::thread;
use std::future::Future;
use std::pin::Pin;
use std::sync::atomic::Ordering::SeqCst;
use std::sync::Arc;
use std::task::Poll::Ready;
use std::task::{Context, Poll};
#[t... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_semaphore_batch.rs | MIT | 0fbde0e94b06536917b6686e996856a33aeb29ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0fbde0e94b06536917b6686e996856a33aeb29ee/tokio/src/sync/tests/loom_semaphore_batch.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/tests/loom_semaphore_batch.rs:3 | for _ in 0..2 {
block_on(semaphore.acquire(1)).map_err(|_| ())?;
semaphore.release(1);
}
Ok::<(), ()>(())
});
}
semaphore.close();
});
}
#[test]
fn concurrent_close() {
const NUM: usize = 3;
loom::model(... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_semaphore_batch.rs | MIT | 0fbde0e94b06536917b6686e996856a33aeb29ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0fbde0e94b06536917b6686e996856a33aeb29ee/tokio/src/sync/tests/loom_semaphore_batch.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/tests/loom_semaphore_batch.rs:4 | poll_fn(|cx| {
// poll the acquire future once, and then immediately throw
// it away. this simulates a situation where a future is
// polled and then cancelled, such as by a timeout.
if let Some(acquire) = acquire1.take() {
pin!(acquire);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_semaphore_batch.rs | MIT | 0fbde0e94b06536917b6686e996856a33aeb29ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0fbde0e94b06536917b6686e996856a33aeb29ee/tokio/src/sync/tests/loom_semaphore_batch.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/tests/loom_semaphore_batch.rs:5 | fn batch() {
let mut b = loom::model::Builder::new();
b.preemption_bound = Some(1);
b.check(|| {
let semaphore = Arc::new(Semaphore::new(10));
let active = Arc::new(AtomicUsize::new(0));
let mut ths = vec![];
for _ in 0..2 {
let semaphore = semaphore.clone();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_semaphore_batch.rs | MIT | 0fbde0e94b06536917b6686e996856a33aeb29ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0fbde0e94b06536917b6686e996856a33aeb29ee/tokio/src/sync/tests/loom_semaphore_batch.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/tests/loom_semaphore_batch.rs:6 | fn release_during_acquire() {
loom::model(|| {
let semaphore = Arc::new(Semaphore::new(10));
semaphore
.try_acquire(8)
.expect("try_acquire should succeed; semaphore uncontended");
let semaphore2 = semaphore.clone();
let thread = thread::spawn(move || block_on... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_semaphore_batch.rs | MIT | 0fbde0e94b06536917b6686e996856a33aeb29ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0fbde0e94b06536917b6686e996856a33aeb29ee/tokio/src/sync/tests/loom_semaphore_batch.rs | 201 | 243 |
tokio-rs/tokio:tokio/src/sync/tests/loom_semaphore_batch.rs:5 | fn batch() {
let mut b = loom::model::Builder::new();
b.preemption_bound = Some(1);
b.check(|| {
let semaphore = Arc::new(Semaphore::new(10));
let active = Arc::new(AtomicUsize::new(0));
let mut ths = vec![];
for _ in 0..2 {
let semaphore = semaphore.clone();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_semaphore_batch.rs | MIT | 00725f6876821f2ec5246a807563e35c5e53f3e1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/00725f6876821f2ec5246a807563e35c5e53f3e1/tokio/src/sync/tests/loom_semaphore_batch.rs | 161 | 215 |
tokio-rs/tokio:tokio/src/sync/tests/loom_semaphore_batch.rs:6 | fn release_during_acquire() {
loom::model(|| {
let semaphore = Arc::new(Semaphore::new(10));
semaphore
.try_acquire(8)
.expect("try_acquire should succeed; semaphore uncontended");
let semaphore2 = semaphore.clone();
let thread = thread::spawn(move || block_on... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_semaphore_batch.rs | MIT | 00725f6876821f2ec5246a807563e35c5e53f3e1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/00725f6876821f2ec5246a807563e35c5e53f3e1/tokio/src/sync/tests/loom_semaphore_batch.rs | 201 | 215 |
tokio-rs/tokio:tokio/src/sync/tests/loom_semaphore_batch.rs:3 | for _ in 0..2 {
block_on(semaphore.acquire(1)).map_err(|_| ())?;
semaphore.release(1);
}
Ok::<(), ()>(())
});
}
semaphore.close();
});
}
#[test]
fn concurrent_close() {
const NUM: usize = 3;
loom::model(... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_semaphore_batch.rs | MIT | acf8a7da7a64bf08d578db9a9836a8e061765314 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/acf8a7da7a64bf08d578db9a9836a8e061765314/tokio/src/sync/tests/loom_semaphore_batch.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/tests/loom_semaphore_batch.rs:4 | b.check(|| {
let semaphore = Arc::new(Semaphore::new(10));
let active = Arc::new(AtomicUsize::new(0));
let mut ths = vec![];
for _ in 0..2 {
let semaphore = semaphore.clone();
let active = active.clone();
ths.push(thread::spawn(move || {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_semaphore_batch.rs | MIT | acf8a7da7a64bf08d578db9a9836a8e061765314 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/acf8a7da7a64bf08d578db9a9836a8e061765314/tokio/src/sync/tests/loom_semaphore_batch.rs | 121 | 171 |
tokio-rs/tokio:tokio/src/sync/tests/loom_semaphore_batch.rs:5 | .try_acquire(8)
.expect("try_acquire should succeed; semaphore uncontended");
let semaphore2 = semaphore.clone();
let thread = thread::spawn(move || block_on(semaphore2.acquire(4)).unwrap());
semaphore.release(8);
thread.join().unwrap();
semaphore.release(4);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_semaphore_batch.rs | MIT | acf8a7da7a64bf08d578db9a9836a8e061765314 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/acf8a7da7a64bf08d578db9a9836a8e061765314/tokio/src/sync/tests/loom_semaphore_batch.rs | 161 | 171 |
tokio-rs/tokio:tokio/src/sync/tests/loom_semaphore_ll.rs:1 | use crate::sync::semaphore_ll::*;
use futures::future::poll_fn;
use loom::future::block_on;
use loom::thread;
use std::future::Future;
use std::pin::Pin;
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering::SeqCst;
use std::sync::Arc;
use std::task::Poll::Ready;
use std::task::{Context, Poll};
#[test]... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_semaphore_ll.rs | MIT | efcbf9613f2d5048550f9c828e3be422644f1391 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/efcbf9613f2d5048550f9c828e3be422644f1391/tokio/src/sync/tests/loom_semaphore_ll.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/tests/loom_semaphore_ll.rs:2 | me.waiter.release(1, &me.shared.semaphore);
Ready(())
}
}
loom::model(|| {
let shared = Arc::new(Shared {
semaphore: Semaphore::new(NUM),
active: AtomicUsize::new(0),
});
for _ in 0..NUM {
let shared = shared.clone();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_semaphore_ll.rs | MIT | efcbf9613f2d5048550f9c828e3be422644f1391 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/efcbf9613f2d5048550f9c828e3be422644f1391/tokio/src/sync/tests/loom_semaphore_ll.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/tests/loom_semaphore_ll.rs:3 | block_on(poll_fn(|cx| permit.poll_acquire(cx, 1, &semaphore))).unwrap();
permit.release(1, &semaphore);
});
}
let mut permit = Permit::new();
block_on(poll_fn(|cx| permit.poll_acquire(cx, 1, &semaphore))).unwrap();
permit.release(1, &semaphore);
});
}
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_semaphore_ll.rs | MIT | efcbf9613f2d5048550f9c828e3be422644f1391 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/efcbf9613f2d5048550f9c828e3be422644f1391/tokio/src/sync/tests/loom_semaphore_ll.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/tests/loom_semaphore_ll.rs:4 | semaphore.close();
});
}
#[test]
fn concurrent_close() {
const NUM: usize = 3;
loom::model(|| {
let semaphore = Arc::new(Semaphore::new(1));
for _ in 0..NUM {
let semaphore = semaphore.clone();
thread::spawn(move || {
let mut permit = Permit::new()... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_semaphore_ll.rs | MIT | efcbf9613f2d5048550f9c828e3be422644f1391 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/efcbf9613f2d5048550f9c828e3be422644f1391/tokio/src/sync/tests/loom_semaphore_ll.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/tests/loom_semaphore_ll.rs:5 | for _ in 0..2 {
let semaphore = semaphore.clone();
let active = active.clone();
ths.push(thread::spawn(move || {
let mut permit = Permit::new();
for n in &[4, 10, 8] {
block_on(poll_fn(|cx| permit.poll_acquire(cx, *n, &semaphore))... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_semaphore_ll.rs | MIT | efcbf9613f2d5048550f9c828e3be422644f1391 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/efcbf9613f2d5048550f9c828e3be422644f1391/tokio/src/sync/tests/loom_semaphore_ll.rs | 161 | 192 |
tokio-rs/tokio:tokio/src/sync/tests/loom_set_once.rs:1 | use crate::sync::SetOnce;
use loom::future::block_on;
use loom::sync::atomic::AtomicU32;
use loom::thread;
use std::sync::atomic::Ordering;
use std::sync::Arc;
#[derive(Clone)]
struct DropCounter {
pub drops: Arc<AtomicU32>,
}
impl DropCounter {
pub fn new() -> Self {
Self {
drops: Arc::n... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_set_once.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/tests/loom_set_once.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/tests/loom_set_once.rs:2 | let thread = thread::spawn(move || set_once_clone.set(counter_cl).is_ok());
let foo = drop_counter.clone();
let set = set_once.set(foo).is_ok();
let res = thread.join().unwrap();
drop(set_once);
drop_counter.assert_num_drops(2);
assert!(res != set);
});
}
#[test]... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_set_once.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/tests/loom_set_once.rs | 41 | 72 |
tokio-rs/tokio:tokio/src/sync/tests/loom_watch.rs:1 | use crate::sync::watch;
use loom::future::block_on;
use loom::thread;
use std::sync::Arc;
#[test]
fn smoke() {
loom::model(|| {
let (tx, mut rx1) = watch::channel(1);
let mut rx2 = rx1.clone();
let mut rx3 = rx1.clone();
let mut rx4 = rx1.clone();
let mut rx5 = rx1.clone();... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_watch.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/tests/loom_watch.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/tests/loom_watch.rs:2 | loom::model(move || {
let (tx, mut rx) = watch::channel(false);
let tx_arc = Arc::new(tx);
let tx1 = tx_arc.clone();
let tx2 = tx_arc.clone();
let th1 = thread::spawn(move || {
for _ in 0..2 {
tx1.send_modify(|_x| {});
}
});
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_watch.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/tests/loom_watch.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/tests/loom_watch.rs:3 | }))
.unwrap();
// Check that it returned the same value as the one we returned
// `true` for.
assert_eq!(stopped_at, returned);
jh.join().unwrap();
});
}
#[test]
fn multiple_sender_drop_concurrently() {
loom::model(move || {
let (tx1, rx) = watch::channel(0);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_watch.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/tests/loom_watch.rs | 81 | 110 |
tokio-rs/tokio:tokio/src/sync/tests/loom_watch.rs:2 | loom::model(move || {
let (tx, mut rx) = watch::channel(false);
let tx_arc = Arc::new(tx);
let tx1 = tx_arc.clone();
let tx2 = tx_arc.clone();
let th1 = thread::spawn(move || {
for _ in 0..2 {
tx1.send_modify(|_x| {});
}
});
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_watch.rs | MIT | c1778eda38d5df316bc8356f2a7aa9f2d2e9abf0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c1778eda38d5df316bc8356f2a7aa9f2d2e9abf0/tokio/src/sync/tests/loom_watch.rs | 41 | 90 |
tokio-rs/tokio:tokio/src/sync/tests/loom_watch.rs:3 | }))
.unwrap();
// Check that it returned the same value as the one we returned
// `true` for.
assert_eq!(stopped_at, returned);
jh.join().unwrap();
});
} | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_watch.rs | MIT | c1778eda38d5df316bc8356f2a7aa9f2d2e9abf0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c1778eda38d5df316bc8356f2a7aa9f2d2e9abf0/tokio/src/sync/tests/loom_watch.rs | 81 | 90 |
tokio-rs/tokio:tokio/src/sync/tests/loom_watch.rs:1 | use crate::sync::watch;
use loom::future::block_on;
use loom::thread;
#[test]
fn smoke() {
loom::model(|| {
let (tx, mut rx1) = watch::channel(1);
let mut rx2 = rx1.clone();
let mut rx3 = rx1.clone();
let mut rx4 = rx1.clone();
let mut rx5 = rx1.clone();
let th = t... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_watch.rs | MIT | e7091fde786722a5301270e6281fc3c449dcfc14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e7091fde786722a5301270e6281fc3c449dcfc14/tokio/src/sync/tests/loom_watch.rs | 1 | 36 |
tokio-rs/tokio:tokio/src/sync/tests/loom_watch.rs:1 | use crate::sync::watch;
use loom::future::block_on;
use loom::thread;
#[test]
fn smoke() {
loom::model(|| {
let (tx, mut rx) = watch::channel(1);
let th = thread::spawn(move || {
tx.send(2).unwrap();
});
block_on(rx.changed()).unwrap();
assert_eq!(*rx.borrow()... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/loom_watch.rs | MIT | 2bc9a4815259c8ff4daa5e24f128ec826970d17f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2bc9a4815259c8ff4daa5e24f128ec826970d17f/tokio/src/sync/tests/loom_watch.rs | 1 | 20 |
tokio-rs/tokio:tokio/src/sync/tests/mod.rs:1 | cfg_not_loom! {
mod atomic_waker;
mod notify;
mod semaphore_batch;
}
cfg_loom! {
mod loom_atomic_waker;
mod loom_broadcast;
mod loom_list;
mod loom_mpsc;
mod loom_notify;
mod loom_oneshot;
mod loom_semaphore_batch;
mod loom_watch;
mod loom_rwlock;
mod loom_set_once;
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/mod.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/tests/mod.rs | 1 | 18 |
tokio-rs/tokio:tokio/src/sync/tests/mod.rs:1 | cfg_not_loom! {
mod atomic_waker;
mod notify;
mod semaphore_batch;
}
cfg_loom! {
mod loom_atomic_waker;
mod loom_broadcast;
mod loom_list;
mod loom_mpsc;
mod loom_notify;
mod loom_oneshot;
mod loom_semaphore_batch;
mod loom_watch;
mod loom_rwlock;
} | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/mod.rs | MIT | ea19606bc459ddacca7ba5be54d93ec766ab8c25 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ea19606bc459ddacca7ba5be54d93ec766ab8c25/tokio/src/sync/tests/mod.rs | 1 | 17 |
tokio-rs/tokio:tokio/src/sync/tests/mod.rs:1 | cfg_not_loom! {
mod atomic_waker;
mod semaphore_batch;
}
cfg_loom! {
mod loom_atomic_waker;
mod loom_broadcast;
mod loom_list;
mod loom_mpsc;
mod loom_notify;
mod loom_oneshot;
mod loom_semaphore_batch;
mod loom_watch;
mod loom_rwlock;
} | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/mod.rs | MIT | e804f88d60071f0d89db85aaa4a073857904b545 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e804f88d60071f0d89db85aaa4a073857904b545/tokio/src/sync/tests/mod.rs | 1 | 16 |
tokio-rs/tokio:tokio/src/sync/tests/mod.rs:1 | cfg_not_loom! {
mod atomic_waker;
mod semaphore_batch;
}
cfg_loom! {
mod loom_atomic_waker;
mod loom_broadcast;
mod loom_list;
mod loom_mpsc;
mod loom_notify;
mod loom_oneshot;
mod loom_semaphore_batch;
mod loom_watch;
} | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/mod.rs | MIT | cf025ba45f68934ae2138bb75ee2a5ee50506d1b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cf025ba45f68934ae2138bb75ee2a5ee50506d1b/tokio/src/sync/tests/mod.rs | 1 | 15 |
tokio-rs/tokio:tokio/src/sync/tests/mod.rs:1 | cfg_not_loom! {
mod atomic_waker;
mod semaphore_ll;
mod semaphore_batch;
}
cfg_loom! {
mod loom_atomic_waker;
mod loom_broadcast;
mod loom_list;
mod loom_mpsc;
mod loom_notify;
mod loom_oneshot;
mod loom_semaphore_batch;
mod loom_semaphore_ll;
mod loom_watch;
} | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/mod.rs | MIT | 2bc9a4815259c8ff4daa5e24f128ec826970d17f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2bc9a4815259c8ff4daa5e24f128ec826970d17f/tokio/src/sync/tests/mod.rs | 1 | 17 |
tokio-rs/tokio:tokio/src/sync/tests/mod.rs:1 | cfg_not_loom! {
mod atomic_waker;
mod semaphore_ll;
mod semaphore_batch;
}
cfg_loom! {
mod loom_atomic_waker;
mod loom_broadcast;
mod loom_list;
mod loom_mpsc;
mod loom_notify;
mod loom_oneshot;
mod loom_semaphore_batch;
mod loom_semaphore_ll;
} | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/mod.rs | MIT | 9d58b70151d7dbb66139125520d383401396eb98 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9d58b70151d7dbb66139125520d383401396eb98/tokio/src/sync/tests/mod.rs | 1 | 16 |
tokio-rs/tokio:tokio/src/sync/tests/mod.rs:1 | cfg_not_loom! {
mod atomic_waker;
mod semaphore_ll;
mod semaphore_batch;
}
cfg_loom! {
mod loom_atomic_waker;
mod loom_broadcast;
#[cfg(tokio_unstable)]
mod loom_cancellation_token;
mod loom_list;
mod loom_mpsc;
mod loom_notify;
mod loom_oneshot;
mod loom_semaphore_batch... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/mod.rs | MIT | 187af2e6a323be4193c82ad95f9aa32d2ae16869 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/187af2e6a323be4193c82ad95f9aa32d2ae16869/tokio/src/sync/tests/mod.rs | 1 | 18 |
tokio-rs/tokio:tokio/src/sync/tests/mod.rs:1 | cfg_not_loom! {
mod atomic_waker;
mod semaphore_ll;
}
cfg_loom! {
mod loom_atomic_waker;
mod loom_broadcast;
mod loom_list;
mod loom_mpsc;
mod loom_notify;
mod loom_oneshot;
mod loom_semaphore_ll;
} | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/mod.rs | MIT | 8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8b7ea0ff5cad2522d3113b77e9b6d95b507dee3b/tokio/src/sync/tests/mod.rs | 1 | 14 |
tokio-rs/tokio:tokio/src/sync/tests/mod.rs:1 | cfg_not_loom! {
mod atomic_waker;
mod semaphore_ll;
}
cfg_loom! {
mod loom_atomic_waker;
mod loom_broadcast;
mod loom_list;
mod loom_mpsc;
mod loom_oneshot;
mod loom_semaphore_ll;
} | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/mod.rs | MIT | 7c010ed030d0084d38451bbebf727c6695c2dbac | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7c010ed030d0084d38451bbebf727c6695c2dbac/tokio/src/sync/tests/mod.rs | 1 | 13 |
tokio-rs/tokio:tokio/src/sync/tests/mod.rs:1 | cfg_not_loom! {
mod atomic_waker;
mod semaphore_ll;
}
cfg_loom! {
mod loom_atomic_waker;
mod loom_list;
mod loom_mpsc;
mod loom_oneshot;
mod loom_semaphore_ll;
} | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/mod.rs | MIT | 9211adbe01661585cd1831214279262024d04816 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9211adbe01661585cd1831214279262024d04816/tokio/src/sync/tests/mod.rs | 1 | 12 |
tokio-rs/tokio:tokio/src/sync/tests/mod.rs:1 | cfg_not_loom! {
mod atomic_waker;
mod semaphore;
}
cfg_loom! {
mod loom_atomic_waker;
mod loom_list;
mod loom_mpsc;
mod loom_oneshot;
mod loom_semaphore;
} | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/mod.rs | MIT | 0d38936b35779b604770120da2e98560bbb6241f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/sync/tests/mod.rs | 1 | 12 |
tokio-rs/tokio:tokio/src/sync/tests/mod.rs:1 | #[cfg(not(loom))]
mod atomic_waker;
#[cfg(loom)]
mod loom_atomic_waker;
#[cfg(loom)]
mod loom_list;
#[cfg(loom)]
mod loom_mpsc;
#[cfg(loom)]
mod loom_oneshot;
#[cfg(loom)]
mod loom_semaphore; | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/mod.rs | MIT | c147be04374534cf7062ea5e7062c4767ba0e2f7 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c147be04374534cf7062ea5e7062c4767ba0e2f7/tokio/src/sync/tests/mod.rs | 1 | 17 |
tokio-rs/tokio:tokio/src/sync/tests/mod.rs:1 | #![cfg(loom)]
mod loom_atomic_waker;
mod loom_list;
mod loom_mpsc;
mod loom_oneshot;
mod loom_semaphore; | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/mod.rs | MIT | 2b909d6805990abf0bc2a5dea9e7267ff87df704 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2b909d6805990abf0bc2a5dea9e7267ff87df704/tokio/src/sync/tests/mod.rs | 1 | 7 |
tokio-rs/tokio:tokio/src/sync/tests/notify.rs:1 | use crate::sync::Notify;
use std::future::Future;
use std::sync::Arc;
use std::task::{Context, RawWaker, RawWakerVTable, Waker};
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[test]
fn notify_clones_waker_before_lock() {
const VTABLE: &RawWakerVTab... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/notify.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/tests/notify.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/tests/notify.rs:2 | let mut cx = Context::from_waker(&waker);
let future = notify.notified();
pin!(future);
// The result doesn't matter, we're just testing that we don't deadlock.
let _ = future.poll(&mut cx);
}
#[cfg(panic = "unwind")]
#[test]
fn notify_waiters_handles_panicking_waker() {
use futures::task::ArcWak... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/notify.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/tests/notify.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/tests/notify.rs:3 | })
.is_err());
for mut fut in futs {
assert!(fut.poll().is_ready());
}
}
#[test]
fn notify_simple() {
let notify = Notify::new();
let mut fut1 = tokio_test::task::spawn(notify.notified());
assert!(fut1.poll().is_pending());
let mut fut2 = tokio_test::task::spawn(notify.notified()... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/notify.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/tests/notify.rs | 81 | 121 |
tokio-rs/tokio:tokio/src/sync/tests/notify.rs:1 | use crate::sync::Notify;
use std::future::Future;
use std::sync::Arc;
use std::task::{Context, RawWaker, RawWakerVTable, Waker};
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[test]
fn notify_clones_waker_before_lock() {
const VTABLE: &RawWakerVTab... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/notify.rs | MIT | bb25a06f348c8069308e6145623dd3743d87564d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bb25a06f348c8069308e6145623dd3743d87564d/tokio/src/sync/tests/notify.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/tests/notify.rs:2 | let future = notify.notified();
pin!(future);
// The result doesn't matter, we're just testing that we don't deadlock.
let _ = future.poll(&mut cx);
}
#[cfg(panic = "unwind")]
#[test]
fn notify_waiters_handles_panicking_waker() {
use futures::task::ArcWake;
let notify = Arc::new(Notify::new());
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/notify.rs | MIT | bb25a06f348c8069308e6145623dd3743d87564d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bb25a06f348c8069308e6145623dd3743d87564d/tokio/src/sync/tests/notify.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/tests/notify.rs:3 | for mut fut in futs {
assert!(fut.poll().is_ready());
}
}
#[test]
fn notify_simple() {
let notify = Notify::new();
let mut fut1 = tokio_test::task::spawn(notify.notified());
assert!(fut1.poll().is_pending());
let mut fut2 = tokio_test::task::spawn(notify.notified());
assert!(fut2.poll... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/notify.rs | MIT | bb25a06f348c8069308e6145623dd3743d87564d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/bb25a06f348c8069308e6145623dd3743d87564d/tokio/src/sync/tests/notify.rs | 81 | 119 |
tokio-rs/tokio:tokio/src/sync/tests/notify.rs:1 | use crate::sync::Notify;
use std::future::Future;
use std::sync::Arc;
use std::task::{Context, RawWaker, RawWakerVTable, Waker};
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[test]
fn notify_clones_waker_before_lock() {
const VTABLE: &RawWakerVTab... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/notify.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/src/sync/tests/notify.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/tests/notify.rs:2 | let future = notify.notified();
pin!(future);
// The result doesn't matter, we're just testing that we don't deadlock.
let _ = future.poll(&mut cx);
}
#[cfg(panic = "unwind")]
#[test]
fn notify_waiters_handles_panicking_waker() {
use futures::task::ArcWake;
let notify = Arc::new(Notify::new());
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/notify.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/src/sync/tests/notify.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/tests/notify.rs:1 | use crate::sync::Notify;
use std::future::Future;
use std::sync::Arc;
use std::task::{Context, RawWaker, RawWakerVTable, Waker};
#[cfg(tokio_wasm_not_wasi)]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[test]
fn notify_clones_waker_before_lock() {
const VTABLE: &RawWakerVTable = &RawWakerVTable::new(clone_w... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/notify.rs | MIT | 267a23158151b6b1e78d5d547fa9455217f79b3c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/267a23158151b6b1e78d5d547fa9455217f79b3c/tokio/src/sync/tests/notify.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/tests/notify.rs:3 | for mut fut in futs {
assert!(fut.poll().is_ready());
}
}
#[test]
fn notify_simple() {
let notify = Notify::new();
let mut fut1 = tokio_test::task::spawn(notify.notified());
assert!(fut1.poll().is_pending());
let mut fut2 = tokio_test::task::spawn(notify.notified());
assert!(fut2.poll... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/notify.rs | MIT | 267a23158151b6b1e78d5d547fa9455217f79b3c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/267a23158151b6b1e78d5d547fa9455217f79b3c/tokio/src/sync/tests/notify.rs | 81 | 119 |
tokio-rs/tokio:tokio/src/sync/tests/notify.rs:1 | use crate::sync::Notify;
use std::future::Future;
use std::mem::ManuallyDrop;
use std::sync::Arc;
use std::task::{Context, RawWaker, RawWakerVTable, Waker};
#[cfg(tokio_wasm_not_wasi)]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[test]
fn notify_clones_waker_before_lock() {
const VTABLE: &RawWakerVTable = ... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/notify.rs | MIT | 795754a846a29a0c785d4dadfb7a9136f8aba1ab | github | async-runtime | https://github.com/tokio-rs/tokio/blob/795754a846a29a0c785d4dadfb7a9136f8aba1ab/tokio/src/sync/tests/notify.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/tests/notify.rs:2 | let future = notify.notified();
pin!(future);
// The result doesn't matter, we're just testing that we don't deadlock.
let _ = future.poll(&mut cx);
}
#[cfg(panic = "unwind")]
#[test]
fn notify_waiters_handles_panicking_waker() {
use futures::task::ArcWake;
let notify = Arc::new(Notify::new());
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/notify.rs | MIT | 795754a846a29a0c785d4dadfb7a9136f8aba1ab | github | async-runtime | https://github.com/tokio-rs/tokio/blob/795754a846a29a0c785d4dadfb7a9136f8aba1ab/tokio/src/sync/tests/notify.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/tests/notify.rs:3 | .is_err());
for mut fut in futs {
assert!(fut.poll().is_ready());
}
}
#[test]
fn notify_simple() {
let notify = Notify::new();
let mut fut1 = tokio_test::task::spawn(notify.notified());
assert!(fut1.poll().is_pending());
let mut fut2 = tokio_test::task::spawn(notify.notified());
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/notify.rs | MIT | 795754a846a29a0c785d4dadfb7a9136f8aba1ab | github | async-runtime | https://github.com/tokio-rs/tokio/blob/795754a846a29a0c785d4dadfb7a9136f8aba1ab/tokio/src/sync/tests/notify.rs | 81 | 120 |
tokio-rs/tokio:tokio/src/sync/tests/notify.rs:1 | use crate::sync::Notify;
use std::future::Future;
use std::mem::ManuallyDrop;
use std::sync::Arc;
use std::task::{Context, RawWaker, RawWakerVTable, Waker};
#[cfg(tokio_wasm_not_wasi)]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[test]
fn notify_clones_waker_before_lock() {
const VTABLE: &RawWakerVTable = ... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/notify.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/src/sync/tests/notify.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/tests/notify.rs:2 | let future = notify.notified();
pin!(future);
// The result doesn't matter, we're just testing that we don't deadlock.
let _ = future.poll(&mut cx);
}
#[test]
fn notify_simple() {
let notify = Notify::new();
let mut fut1 = tokio_test::task::spawn(notify.notified());
assert!(fut1.poll().is_pen... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/notify.rs | MIT | b2ada60e701d5c9e6644cf8fc42a100774f8e23f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b2ada60e701d5c9e6644cf8fc42a100774f8e23f/tokio/src/sync/tests/notify.rs | 41 | 81 |
tokio-rs/tokio:tokio/src/sync/tests/notify.rs:1 | use crate::sync::Notify;
use std::future::Future;
use std::mem::ManuallyDrop;
use std::sync::Arc;
use std::task::{Context, RawWaker, RawWakerVTable, Waker};
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[test]
fn notify_clones_waker_before_lock() {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/notify.rs | MIT | 0dc62da21b0bffe113e2efa23f6da6ef4e36bf4f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0dc62da21b0bffe113e2efa23f6da6ef4e36bf4f/tokio/src/sync/tests/notify.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/tests/notify.rs:2 | let future = notify.notified();
pin!(future);
// The result doesn't matter, we're just testing that we don't deadlock.
let _ = future.poll(&mut cx);
}
#[test]
fn notify_simple() {
let notify = Notify::new();
let mut fut1 = tokio_test::task::spawn(notify.notified());
assert!(fut1.poll().is_pen... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/notify.rs | MIT | 0dc62da21b0bffe113e2efa23f6da6ef4e36bf4f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0dc62da21b0bffe113e2efa23f6da6ef4e36bf4f/tokio/src/sync/tests/notify.rs | 41 | 81 |
tokio-rs/tokio:tokio/src/sync/tests/notify.rs:1 | use crate::sync::Notify;
use std::future::Future;
use std::mem::ManuallyDrop;
use std::sync::Arc;
use std::task::{Context, RawWaker, RawWakerVTable, Waker};
#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[test]
fn notify_clones_waker_before_lock() {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/notify.rs | MIT | 6d3f92dddc510e9276191cfab1b0432ce8248589 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/src/sync/tests/notify.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/tests/notify.rs:2 | let future = notify.notified();
pin!(future);
// The result doesn't matter, we're just testing that we don't deadlock.
let _ = future.poll(&mut cx);
}
#[test]
fn notify_simple() {
let notify = Notify::new();
let mut fut1 = tokio_test::task::spawn(notify.notified());
assert!(fut1.poll().is_pen... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/notify.rs | MIT | 6d3f92dddc510e9276191cfab1b0432ce8248589 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6d3f92dddc510e9276191cfab1b0432ce8248589/tokio/src/sync/tests/notify.rs | 41 | 81 |
tokio-rs/tokio:tokio/src/sync/tests/notify.rs:1 | use crate::sync::Notify;
use std::future::Future;
use std::mem::ManuallyDrop;
use std::sync::Arc;
use std::task::{Context, RawWaker, RawWakerVTable, Waker};
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[test]
fn notify_clones_waker_before_lock() {
const VTABLE: &RawWakerVTable... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/notify.rs | MIT | 1be8e9dfb7b1140568ac10ac34f5f8171a89e40d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/sync/tests/notify.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/tests/notify.rs:1 | use crate::sync::Notify;
use std::future::Future;
use std::mem::ManuallyDrop;
use std::sync::Arc;
use std::task::{Context, RawWaker, RawWakerVTable, Waker};
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[test]
fn notify_clones_waker_before_lock() {
const VTABLE: &RawWakerVTable... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/notify.rs | MIT | 2747043f6f7e0870cc5aa72c146dfae9543c5ba8 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2747043f6f7e0870cc5aa72c146dfae9543c5ba8/tokio/src/sync/tests/notify.rs | 1 | 47 |
tokio-rs/tokio:tokio/src/sync/tests/notify.rs:1 | use crate::sync::Notify;
use std::future::Future;
use std::mem::ManuallyDrop;
use std::sync::Arc;
use std::task::{Context, RawWaker, RawWakerVTable, Waker};
#[test]
fn notify_clones_waker_before_lock() {
const VTABLE: &RawWakerVTable = &RawWakerVTable::new(clone_w, wake, wake_by_ref, drop_w);
unsafe fn clone_... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/notify.rs | MIT | ea19606bc459ddacca7ba5be54d93ec766ab8c25 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ea19606bc459ddacca7ba5be54d93ec766ab8c25/tokio/src/sync/tests/notify.rs | 1 | 44 |
tokio-rs/tokio:tokio/src/sync/tests/semaphore_batch.rs:1 | use crate::sync::batch_semaphore::Semaphore;
use tokio_test::*;
const MAX_PERMITS: usize = crate::sync::Semaphore::MAX_PERMITS;
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[test]
fn poll_acquire_one_available() {
let s = Semaphore::new(100);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/semaphore_batch.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/tests/semaphore_batch.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/tests/semaphore_batch.rs:2 | assert_eq!(s.available_permits(), 98);
}
#[test]
fn try_acquire_many_available() {
let s = Semaphore::new(100);
assert_eq!(s.available_permits(), 100);
assert_ok!(s.try_acquire(5));
assert_eq!(s.available_permits(), 95);
assert_ok!(s.try_acquire(5));
assert_eq!(s.available_permits(), 90);
}
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/semaphore_batch.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/tests/semaphore_batch.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/tests/semaphore_batch.rs:3 | fn poll_acquire_many_unavailable() {
let s = Semaphore::new(5);
// Acquire the first permit
assert_ready_ok!(task::spawn(s.acquire(1)).poll());
assert_eq!(s.available_permits(), 4);
// Try to acquire the second permit
let mut acquire_2 = task::spawn(s.acquire(5));
assert_pending!(acquire_2... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/semaphore_batch.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/tests/semaphore_batch.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/tests/semaphore_batch.rs:4 | // Acquire the first permit
assert_ok!(s.try_acquire(1));
assert_eq!(s.available_permits(), 0);
assert_err!(s.try_acquire(1));
s.release(1);
assert_eq!(s.available_permits(), 1);
assert_ok!(s.try_acquire(1));
s.release(1);
assert_eq!(s.available_permits(), 1);
}
#[test]
fn try_acqui... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/semaphore_batch.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/tests/semaphore_batch.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/tests/semaphore_batch.rs:5 | assert_eq!(s.available_permits(), 0);
// Try to acquire the permit
let mut acquire = task::spawn(s.acquire(1));
assert_pending!(acquire.poll());
s.release(1);
assert!(acquire.is_woken());
assert_ready_ok!(acquire.poll());
}
#[test]
fn max_permits_doesnt_panic() {
Semaphore::new(MAX_PERMI... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/semaphore_batch.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/tests/semaphore_batch.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/tests/semaphore_batch.rs:6 | let s = Semaphore::new(0);
let mut acquire = task::spawn(s.acquire(1));
assert_pending!(acquire.poll());
s.close();
assert!(acquire.is_woken());
assert_ready_err!(acquire.poll());
}
#[test]
fn close_semaphore_notifies_permit2() {
let s = Semaphore::new(2);
// Acquire a couple of permits... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/semaphore_batch.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/tests/semaphore_batch.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/tests/semaphore_batch.rs:7 | s.release(1);
assert_eq!(2, s.available_permits());
}
#[test]
fn cancel_acquire_releases_permits() {
let s = Semaphore::new(10);
s.try_acquire(4).expect("uncontended try_acquire succeeds");
assert_eq!(6, s.available_permits());
let mut acquire = task::spawn(s.acquire(8));
assert_pending!(acqu... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/semaphore_batch.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/tests/semaphore_batch.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/tests/semaphore_batch.rs:8 | // Second iteration shouldn't deadlock.
for _ in 0..=1 {
let waker = futures::task::waker(Arc::new(ReleaseOnDrop(
sem.clone().try_acquire_owned().ok(),
)));
let mut cx = std::task::Context::from_waker(&waker);
assert!(fut.as_mut().poll(&mut cx).is_pending());
}
}
#[t... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/semaphore_batch.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/tests/semaphore_batch.rs | 281 | 310 |
tokio-rs/tokio:tokio/src/sync/tests/semaphore_batch.rs:7 | s.release(1);
assert_eq!(2, s.available_permits());
}
#[test]
fn cancel_acquire_releases_permits() {
let s = Semaphore::new(10);
s.try_acquire(4).expect("uncontended try_acquire succeeds");
assert_eq!(6, s.available_permits());
let mut acquire = task::spawn(s.acquire(8));
assert_pending!(acqu... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/semaphore_batch.rs | MIT | 0fbde0e94b06536917b6686e996856a33aeb29ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0fbde0e94b06536917b6686e996856a33aeb29ee/tokio/src/sync/tests/semaphore_batch.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/tests/semaphore_batch.rs:7 | s.release(1);
assert_eq!(2, s.available_permits());
}
#[test]
fn cancel_acquire_releases_permits() {
let s = Semaphore::new(10);
s.try_acquire(4).expect("uncontended try_acquire succeeds");
assert_eq!(6, s.available_permits());
let mut acquire = task::spawn(s.acquire(8));
assert_pending!(acqu... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/semaphore_batch.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/src/sync/tests/semaphore_batch.rs | 241 | 289 |
tokio-rs/tokio:tokio/src/sync/tests/semaphore_batch.rs:1 | use crate::sync::batch_semaphore::Semaphore;
use tokio_test::*;
const MAX_PERMITS: usize = crate::sync::Semaphore::MAX_PERMITS;
#[cfg(tokio_wasm_not_wasi)]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[test]
fn poll_acquire_one_available() {
let s = Semaphore::new(100);
assert_eq!(s.available_permits()... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/semaphore_batch.rs | MIT | 822af18cf5fde60b134943067647ee35405c3797 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/822af18cf5fde60b134943067647ee35405c3797/tokio/src/sync/tests/semaphore_batch.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/tests/semaphore_batch.rs:4 | // Acquire the first permit
assert_ok!(s.try_acquire(1));
assert_eq!(s.available_permits(), 0);
assert_err!(s.try_acquire(1));
s.release(1);
assert_eq!(s.available_permits(), 1);
assert_ok!(s.try_acquire(1));
s.release(1);
assert_eq!(s.available_permits(), 1);
}
#[test]
fn try_acqui... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/semaphore_batch.rs | MIT | 822af18cf5fde60b134943067647ee35405c3797 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/822af18cf5fde60b134943067647ee35405c3797/tokio/src/sync/tests/semaphore_batch.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/tests/semaphore_batch.rs:5 | assert_eq!(s.available_permits(), 0);
// Try to acquire the permit
let mut acquire = task::spawn(s.acquire(1));
assert_pending!(acquire.poll());
s.release(1);
assert!(acquire.is_woken());
assert_ready_ok!(acquire.poll());
}
#[test]
fn max_permits_doesnt_panic() {
Semaphore::new(MAX_PERMI... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/semaphore_batch.rs | MIT | 822af18cf5fde60b134943067647ee35405c3797 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/822af18cf5fde60b134943067647ee35405c3797/tokio/src/sync/tests/semaphore_batch.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/tests/semaphore_batch.rs:1 | use crate::sync::batch_semaphore::Semaphore;
use tokio_test::*;
#[cfg(tokio_wasm_not_wasi)]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[test]
fn poll_acquire_one_available() {
let s = Semaphore::new(100);
assert_eq!(s.available_permits(), 100);
// Polling for a permit succeeds immediately
ass... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/semaphore_batch.rs | MIT | 901f6d26c6aefd25a8f180e7a12ea8ed3c88ace2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/901f6d26c6aefd25a8f180e7a12ea8ed3c88ace2/tokio/src/sync/tests/semaphore_batch.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/tests/semaphore_batch.rs:2 | #[test]
fn try_acquire_many_available() {
let s = Semaphore::new(100);
assert_eq!(s.available_permits(), 100);
assert_ok!(s.try_acquire(5));
assert_eq!(s.available_permits(), 95);
assert_ok!(s.try_acquire(5));
assert_eq!(s.available_permits(), 90);
}
#[test]
fn poll_acquire_one_unavailable() ... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/semaphore_batch.rs | MIT | 901f6d26c6aefd25a8f180e7a12ea8ed3c88ace2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/901f6d26c6aefd25a8f180e7a12ea8ed3c88ace2/tokio/src/sync/tests/semaphore_batch.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/tests/semaphore_batch.rs:3 | // Acquire the first permit
assert_ready_ok!(task::spawn(s.acquire(1)).poll());
assert_eq!(s.available_permits(), 4);
// Try to acquire the second permit
let mut acquire_2 = task::spawn(s.acquire(5));
assert_pending!(acquire_2.poll());
assert_eq!(s.available_permits(), 0);
// Try to acquir... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/semaphore_batch.rs | MIT | 901f6d26c6aefd25a8f180e7a12ea8ed3c88ace2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/901f6d26c6aefd25a8f180e7a12ea8ed3c88ace2/tokio/src/sync/tests/semaphore_batch.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/tests/semaphore_batch.rs:4 | assert_eq!(s.available_permits(), 0);
assert_err!(s.try_acquire(1));
s.release(1);
assert_eq!(s.available_permits(), 1);
assert_ok!(s.try_acquire(1));
s.release(1);
assert_eq!(s.available_permits(), 1);
}
#[test]
fn try_acquire_many_unavailable() {
let s = Semaphore::new(5);
// Acq... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/semaphore_batch.rs | MIT | 901f6d26c6aefd25a8f180e7a12ea8ed3c88ace2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/901f6d26c6aefd25a8f180e7a12ea8ed3c88ace2/tokio/src/sync/tests/semaphore_batch.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/tests/semaphore_batch.rs:5 | // Try to acquire the permit
let mut acquire = task::spawn(s.acquire(1));
assert_pending!(acquire.poll());
s.release(1);
assert!(acquire.is_woken());
assert_ready_ok!(acquire.poll());
}
#[test]
#[should_panic]
#[cfg(not(tokio_wasm))] // wasm currently doesn't support unwinding
fn validates_max_pe... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/semaphore_batch.rs | MIT | 901f6d26c6aefd25a8f180e7a12ea8ed3c88ace2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/901f6d26c6aefd25a8f180e7a12ea8ed3c88ace2/tokio/src/sync/tests/semaphore_batch.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/tests/semaphore_batch.rs:6 | assert!(acquire.is_woken());
assert_ready_err!(acquire.poll());
}
#[test]
fn close_semaphore_notifies_permit2() {
let s = Semaphore::new(2);
// Acquire a couple of permits
assert_ready_ok!(task::spawn(s.acquire(1)).poll());
assert_ready_ok!(task::spawn(s.acquire(1)).poll());
let mut acquire3 ... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/sync/tests/semaphore_batch.rs | MIT | 901f6d26c6aefd25a8f180e7a12ea8ed3c88ace2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/901f6d26c6aefd25a8f180e7a12ea8ed3c88ace2/tokio/src/sync/tests/semaphore_batch.rs | 201 | 260 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.