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/barrier.rs:3 | /// will receive a result that will return `false` from `is_leader`.
pub async fn wait(&self) -> BarrierWaitResult {
// NOTE: we are taking a _synchronous_ lock here.
// It is okay to do so because the critical section is fast and never yields, so it cannot
// deadlock even if another future... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/barrier.rs | MIT | 2bc9a4815259c8ff4daa5e24f128ec826970d17f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2bc9a4815259c8ff4daa5e24f128ec826970d17f/tokio/src/sync/barrier.rs | 81 | 138 |
tokio-rs/tokio:tokio/src/sync/barrier.rs:4 | BarrierWaitResult(false)
}
}
/// A `BarrierWaitResult` is returned by `wait` when all threads in the `Barrier` have rendezvoused.
#[derive(Debug, Clone)]
pub struct BarrierWaitResult(bool);
impl BarrierWaitResult {
/// Returns `true` if this thread from wait is the "leader thread".
///
/// Only one th... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/barrier.rs | MIT | 2bc9a4815259c8ff4daa5e24f128ec826970d17f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2bc9a4815259c8ff4daa5e24f128ec826970d17f/tokio/src/sync/barrier.rs | 121 | 138 |
tokio-rs/tokio:tokio/src/sync/barrier.rs:3 | /// will receive a result that will return `false` from `is_leader`.
pub async fn wait(&self) -> BarrierWaitResult {
// NOTE: we are taking a _synchronous_ lock here.
// It is okay to do so because the critical section is fast and never yields, so it cannot
// deadlock even if another future... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/barrier.rs | MIT | 5a1a6dc90c6d5a7eb5f31ae215f9ec383d6767aa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5a1a6dc90c6d5a7eb5f31ae215f9ec383d6767aa/tokio/src/sync/barrier.rs | 81 | 136 |
tokio-rs/tokio:tokio/src/sync/barrier.rs:4 | }
}
/// A `BarrierWaitResult` is returned by `wait` when all threads in the `Barrier` have rendezvoused.
#[derive(Debug, Clone)]
pub struct BarrierWaitResult(bool);
impl BarrierWaitResult {
/// Returns `true` if this thread from wait is the "leader thread".
///
/// Only one thread will have `true` returne... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/barrier.rs | MIT | 5a1a6dc90c6d5a7eb5f31ae215f9ec383d6767aa | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5a1a6dc90c6d5a7eb5f31ae215f9ec383d6767aa/tokio/src/sync/barrier.rs | 121 | 136 |
tokio-rs/tokio:tokio/src/sync/barrier.rs:2 | #[derive(Debug)]
struct BarrierState {
waker: watch::Sender<usize>,
arrived: usize,
generation: usize,
}
impl Barrier {
/// Creates a new barrier that can block a given number of threads.
///
/// A barrier will block `n`-1 threads which call [`Barrier::wait`] and then wake up all
/// thread... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/barrier.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/sync/barrier.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/barrier.rs:3 | /// will receive a result that will return `false` from `is_leader`.
pub async fn wait(&self) -> BarrierWaitResult {
// NOTE: we are taking a _synchronous_ lock here.
// It is okay to do so because the critical section is fast and never yields, so it cannot
// deadlock even if another future... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/barrier.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/sync/barrier.rs | 81 | 136 |
tokio-rs/tokio:tokio/src/sync/barrier.rs:3 | /// will receive a result that will return `false` from `is_leader`.
pub async fn wait(&self) -> BarrierWaitResult {
// NOTE: we are taking a _synchronous_ lock here.
// It is okay to do so because the critical section is fast and never yields, so it cannot
// deadlock even if another future... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/barrier.rs | MIT | 8a7e57786a5dca139f5b4261685e22991ded0859 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/sync/barrier.rs | 81 | 136 |
tokio-rs/tokio:tokio/src/sync/barrier.rs:4 | }
}
/// A `BarrierWaitResult` is returned by `wait` when all threads in the `Barrier` have rendezvoused.
#[derive(Debug, Clone)]
pub struct BarrierWaitResult(bool);
impl BarrierWaitResult {
/// Returns true if this thread from wait is the "leader thread".
///
/// Only one thread will have `true` returned ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/barrier.rs | MIT | 8a7e57786a5dca139f5b4261685e22991ded0859 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/sync/barrier.rs | 121 | 136 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:1 | #![cfg_attr(not(feature = "sync"), allow(unreachable_pub, dead_code))]
//! # Implementation Details.
//!
//! The semaphore is implemented using an intrusive linked list of waiters. An
//! atomic counter tracks the number of available permits. If the semaphore does
//! not contain the required number of permits, the tas... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/batch_semaphore.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:2 | }
struct Waitlist {
queue: LinkedList<Waiter, <Waiter as linked_list::Link>::Target>,
closed: bool,
}
/// Error returned from the [`Semaphore::try_acquire`] function.
///
/// [`Semaphore::try_acquire`]: crate::sync::Semaphore::try_acquire
#[derive(Debug, PartialEq, Eq)]
pub enum TryAcquireError {
/// The ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/batch_semaphore.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:3 | ///
/// This is either the number of remaining permits required by
/// the waiter, or a flag indicating that the waiter is not yet queued.
state: AtomicUsize,
/// The waker to notify the task awaiting permits.
///
/// # Safety
///
/// This may only be accessed while the wait queue is lo... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/batch_semaphore.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:4 | impl Semaphore {
/// The maximum number of permits which a semaphore can hold.
///
/// Note that this reserves three bits of flags in the permit counter, but
/// we only actually use one of them. However, the previous semaphore
/// implementation used three bits, so we will continue to reserve them ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/batch_semaphore.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:5 | permits.op = "override",
)
});
resource_span
};
Self {
permits: AtomicUsize::new(permits << Self::PERMIT_SHIFT),
waiters: Mutex::new(Waitlist {
queue: LinkedList::new(),
closed: false,
}),
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/batch_semaphore.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:6 | queue: LinkedList::new(),
closed: true,
}),
#[cfg(all(tokio_unstable, feature = "tracing"))]
resource_span: tracing::Span::none(),
}
}
/// Creates a new closed semaphore with 0 permits.
#[cfg(not(all(loom, test)))]
pub(crate) const fn const_ne... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/batch_semaphore.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:7 | /// permits and notifies all pending waiters.
pub(crate) fn close(&self) {
let mut waiters = self.waiters.lock();
// If the semaphore's permits counter has enough permits for an
// unqueued waiter to acquire all the permits it needs immediately,
// it won't touch the wait list. There... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/batch_semaphore.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:8 | if curr < num_permits {
return Err(TryAcquireError::NoPermits);
}
let next = curr - num_permits;
match self.permits.compare_exchange(curr, next, AcqRel, Acquire) {
Ok(_) => {
// TODO: Instrument once issue has been solved
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/batch_semaphore.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:9 | is_empty = true;
// If we assigned permits to all the waiters in the queue, and there are
// still permits left over, assign them back to the semaphore.
break 'inner;
}
};
let mut waiter = waiters... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/batch_semaphore.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:10 | rem = 0;
}
drop(waiters); // release the lock
wakers.wake_all();
}
assert_eq!(rem, 0);
}
/// Decrease a semaphore's permits by a maximum of `n`.
///
/// If there are insufficient permits and it's not possible to reduce by `n`,
/// return the nu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/batch_semaphore.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:11 | node: Pin<&mut Waiter>,
queued: bool,
) -> Poll<Result<(), AcquireError>> {
let mut acquired = 0;
let needed = if queued {
node.state.load(Acquire) << Self::PERMIT_SHIFT
} else {
num_permits << Self::PERMIT_SHIFT
};
let mut lock = None;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/batch_semaphore.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:12 | // added while waiting for the lock.
lock = Some(self.waiters.lock());
}
match self.permits.compare_exchange(curr, next, AcqRel, Acquire) {
Ok(_) => {
acquired += acq;
if remaining == 0 {
if !queued ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/batch_semaphore.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:13 | tracing::trace!(
target: "runtime::resource::state_update",
permits = acquired,
permits.op = "sub",
)
});
if node.assign_permits(&mut acquired) {
self.add_permits_locked(acquired, waiters);
return Poll::Ready(Ok(()));
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/batch_semaphore.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:14 | Poll::Pending
}
}
impl fmt::Debug for Semaphore {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Semaphore")
.field("permits", &self.available_permits())
.finish()
}
}
impl Waiter {
fn new(
num_permits: usize,
#[cfg(all(to... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/batch_semaphore.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:15 | tracing::trace!(
target: "runtime::resource::async_op::state_update",
permits_obtained = assign,
permits.op = "add",
);
});
return next == 0;
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/batch_semaphore.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:16 | Poll::Pending => {
*queued = true;
Poll::Pending
}
Poll::Ready(r) => {
coop.made_progress();
r?;
*queued = false;
Poll::Ready(Ok(()))
}
};
#[cfg(all(tokio_unstable, featur... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/batch_semaphore.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:17 | tracing::trace!(
target: "runtime::resource::async_op::state_update",
permits_obtained = 0usize,
permits.op = "override",
);
tracing::trace_span!("runtime.resource.async_op.poll")
});
let ctx = trace::A... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/batch_semaphore.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:18 | )
}
}
}
impl Drop for Acquire<'_> {
fn drop(&mut self) {
// If the future is completed, there is no node in the wait list, so we
// can skip acquiring the lock.
if !self.queued {
return;
}
// This is where we ensure safety. The future is being droppe... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/batch_semaphore.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:19 | fn closed() -> AcquireError {
AcquireError(())
}
}
impl fmt::Display for AcquireError {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(fmt, "semaphore closed")
}
}
impl std::error::Error for AcquireError {}
// ===== impl TryAcquireError =====
impl TryAcquireError {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/batch_semaphore.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:20 | /// # Safety
///
/// `Waiter` is forced to be !Unpin.
unsafe impl linked_list::Link for Waiter {
type Handle = NonNull<Waiter>;
type Target = Waiter;
fn as_raw(handle: &Self::Handle) -> NonNull<Waiter> {
*handle
}
unsafe fn from_raw(ptr: NonNull<Waiter>) -> NonNull<Waiter> {
ptr
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/sync/batch_semaphore.rs | 761 | 780 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:14 | Poll::Pending
}
}
impl fmt::Debug for Semaphore {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Semaphore")
.field("permits", &self.available_permits())
.finish()
}
}
impl Waiter {
fn new(
num_permits: usize,
#[cfg(all(to... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 3ea11e2a5fb4139ca21b441044d98994a2b126c5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3ea11e2a5fb4139ca21b441044d98994a2b126c5/tokio/src/sync/batch_semaphore.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:15 | tracing::trace!(
target: "runtime::resource::async_op::state_update",
permits_obtained = assign,
permits.op = "add",
);
});
return next == 0;
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 3ea11e2a5fb4139ca21b441044d98994a2b126c5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3ea11e2a5fb4139ca21b441044d98994a2b126c5/tokio/src/sync/batch_semaphore.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:10 | rem = 0;
}
drop(waiters); // release the lock
wakers.wake_all();
}
assert_eq!(rem, 0);
}
/// Decrease a semaphore's permits by a maximum of `n`.
///
/// If there are insufficient permits and it's not possible to reduce by `n`,
/// return the nu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/665f08b5ad15485e8dcd6c3ec5ad1bda03a2a68d/tokio/src/sync/batch_semaphore.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:19 | fn closed() -> AcquireError {
AcquireError(())
}
}
impl fmt::Display for AcquireError {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(fmt, "semaphore closed")
}
}
impl std::error::Error for AcquireError {}
// ===== impl TryAcquireError =====
impl TryAcquireError {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | a7896d07f1d3093524c7a190b57570dad3767c7a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a7896d07f1d3093524c7a190b57570dad3767c7a/tokio/src/sync/batch_semaphore.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:20 | /// # Safety
///
/// `Waiter` is forced to be !Unpin.
unsafe impl linked_list::Link for Waiter {
type Handle = NonNull<Waiter>;
type Target = Waiter;
fn as_raw(handle: &Self::Handle) -> NonNull<Waiter> {
*handle
}
unsafe fn from_raw(ptr: NonNull<Waiter>) -> NonNull<Waiter> {
ptr
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | a7896d07f1d3093524c7a190b57570dad3767c7a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a7896d07f1d3093524c7a190b57570dad3767c7a/tokio/src/sync/batch_semaphore.rs | 761 | 780 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:13 | tracing::trace!(
target: "runtime::resource::state_update",
permits = acquired,
permits.op = "sub",
)
});
if node.assign_permits(&mut acquired) {
self.add_permits_locked(acquired, waiters);
return Poll::Ready(Ok(()));
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/sync/batch_semaphore.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:15 | tracing::trace!(
target: "runtime::resource::async_op::state_update",
permits_obtained = assign,
permits.op = "add",
);
});
return next == 0;
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/sync/batch_semaphore.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:1 | #![cfg_attr(not(feature = "sync"), allow(unreachable_pub, dead_code))]
//! # Implementation Details.
//!
//! The semaphore is implemented using an intrusive linked list of waiters. An
//! atomic counter tracks the number of available permits. If the semaphore does
//! not contain the required number of permits, the tas... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 0cbf1a5adae81e8ff86ca6d040aeee67cf888262 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0cbf1a5adae81e8ff86ca6d040aeee67cf888262/tokio/src/sync/batch_semaphore.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:4 | impl Semaphore {
/// The maximum number of permits which a semaphore can hold.
///
/// Note that this reserves three bits of flags in the permit counter, but
/// we only actually use one of them. However, the previous semaphore
/// implementation used three bits, so we will continue to reserve them ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | daa89017dad7cecb769d3145c4368ae491a4ac67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/daa89017dad7cecb769d3145c4368ae491a4ac67/tokio/src/sync/batch_semaphore.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:5 | )
});
resource_span
};
Self {
permits: AtomicUsize::new(permits << Self::PERMIT_SHIFT),
waiters: Mutex::new(Waitlist {
queue: LinkedList::new(),
closed: false,
}),
#[cfg(all(tokio_unstable, feature =... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | daa89017dad7cecb769d3145c4368ae491a4ac67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/daa89017dad7cecb769d3145c4368ae491a4ac67/tokio/src/sync/batch_semaphore.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:6 | closed: true,
}),
#[cfg(all(tokio_unstable, feature = "tracing"))]
resource_span: tracing::Span::none(),
}
}
/// Creates a new closed semaphore with 0 permits.
#[cfg(not(all(loom, test)))]
pub(crate) const fn const_new_closed() -> Self {
Self {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | daa89017dad7cecb769d3145c4368ae491a4ac67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/daa89017dad7cecb769d3145c4368ae491a4ac67/tokio/src/sync/batch_semaphore.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:7 | pub(crate) fn close(&self) {
let mut waiters = self.waiters.lock();
// If the semaphore's permits counter has enough permits for an
// unqueued waiter to acquire all the permits it needs immediately,
// it won't touch the wait list. Therefore, we have to set a bit on
// the permi... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | daa89017dad7cecb769d3145c4368ae491a4ac67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/daa89017dad7cecb769d3145c4368ae491a4ac67/tokio/src/sync/batch_semaphore.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:8 | return Err(TryAcquireError::NoPermits);
}
let next = curr - num_permits;
match self.permits.compare_exchange(curr, next, AcqRel, Acquire) {
Ok(_) => {
// TODO: Instrument once issue has been solved
return Ok(());
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | daa89017dad7cecb769d3145c4368ae491a4ac67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/daa89017dad7cecb769d3145c4368ae491a4ac67/tokio/src/sync/batch_semaphore.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:9 | // If we assigned permits to all the waiters in the queue, and there are
// still permits left over, assign them back to the semaphore.
break 'inner;
}
};
let mut waiter = waiters.queue.pop_back().unwrap();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | daa89017dad7cecb769d3145c4368ae491a4ac67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/daa89017dad7cecb769d3145c4368ae491a4ac67/tokio/src/sync/batch_semaphore.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:10 | }
drop(waiters); // release the lock
wakers.wake_all();
}
assert_eq!(rem, 0);
}
/// Decrease a semaphore's permits by a maximum of `n`.
///
/// If there are insufficient permits and it's not possible to reduce by `n`,
/// return the number of permits that ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | daa89017dad7cecb769d3145c4368ae491a4ac67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/daa89017dad7cecb769d3145c4368ae491a4ac67/tokio/src/sync/batch_semaphore.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:11 | queued: bool,
) -> Poll<Result<(), AcquireError>> {
let mut acquired = 0;
let needed = if queued {
node.state.load(Acquire) << Self::PERMIT_SHIFT
} else {
num_permits << Self::PERMIT_SHIFT
};
let mut lock = None;
// First, try to take the req... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | daa89017dad7cecb769d3145c4368ae491a4ac67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/daa89017dad7cecb769d3145c4368ae491a4ac67/tokio/src/sync/batch_semaphore.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:12 | lock = Some(self.waiters.lock());
}
match self.permits.compare_exchange(curr, next, AcqRel, Acquire) {
Ok(_) => {
acquired += acq;
if remaining == 0 {
if !queued {
#[cfg(all(tokio_unstabl... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | daa89017dad7cecb769d3145c4368ae491a4ac67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/daa89017dad7cecb769d3145c4368ae491a4ac67/tokio/src/sync/batch_semaphore.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:13 | target: "runtime::resource::state_update",
permits = acquired,
permits.op = "sub",
)
});
if node.assign_permits(&mut acquired) {
self.add_permits_locked(acquired, waiters);
return Poll::Ready(Ok(()));
}
assert_eq!(acqu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | daa89017dad7cecb769d3145c4368ae491a4ac67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/daa89017dad7cecb769d3145c4368ae491a4ac67/tokio/src/sync/batch_semaphore.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:14 | }
}
impl fmt::Debug for Semaphore {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Semaphore")
.field("permits", &self.available_permits())
.finish()
}
}
impl Waiter {
fn new(
num_permits: usize,
#[cfg(all(tokio_unstable, feat... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | daa89017dad7cecb769d3145c4368ae491a4ac67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/daa89017dad7cecb769d3145c4368ae491a4ac67/tokio/src/sync/batch_semaphore.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:15 | target: "runtime::resource::async_op::state_update",
permits_obtained = assign,
permits.op = "add",
);
});
return next == 0;
}
Err(actual) => curr = actual,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | daa89017dad7cecb769d3145c4368ae491a4ac67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/daa89017dad7cecb769d3145c4368ae491a4ac67/tokio/src/sync/batch_semaphore.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:16 | *queued = true;
Poll::Pending
}
Poll::Ready(r) => {
coop.made_progress();
r?;
*queued = false;
Poll::Ready(Ok(()))
}
};
#[cfg(all(tokio_unstable, feature = "tracing"))]
return tra... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | daa89017dad7cecb769d3145c4368ae491a4ac67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/daa89017dad7cecb769d3145c4368ae491a4ac67/tokio/src/sync/batch_semaphore.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:17 | tracing::trace!(
target: "runtime::resource::async_op::state_update",
permits_obtained = 0usize,
permits.op = "override",
);
tracing::trace_span!("runtime.resource.async_op.poll")
});
let ctx = trace::A... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | daa89017dad7cecb769d3145c4368ae491a4ac67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/daa89017dad7cecb769d3145c4368ae491a4ac67/tokio/src/sync/batch_semaphore.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:18 | }
}
}
impl Drop for Acquire<'_> {
fn drop(&mut self) {
// If the future is completed, there is no node in the wait list, so we
// can skip acquiring the lock.
if !self.queued {
return;
}
// This is where we ensure safety. The future is being dropped,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | daa89017dad7cecb769d3145c4368ae491a4ac67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/daa89017dad7cecb769d3145c4368ae491a4ac67/tokio/src/sync/batch_semaphore.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:19 | AcquireError(())
}
}
impl fmt::Display for AcquireError {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(fmt, "semaphore closed")
}
}
impl std::error::Error for AcquireError {}
// ===== impl TryAcquireError =====
impl TryAcquireError {
/// Returns `true` if the error was... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | daa89017dad7cecb769d3145c4368ae491a4ac67 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/daa89017dad7cecb769d3145c4368ae491a4ac67/tokio/src/sync/batch_semaphore.rs | 721 | 779 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:3 | ///
/// This is either the number of remaining permits required by
/// the waiter, or a flag indicating that the waiter is not yet queued.
state: AtomicUsize,
/// The waker to notify the task awaiting permits.
///
/// # Safety
///
/// This may only be accessed while the wait queue is lo... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 2438b436716ed21432b809a21024f54caebab887 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2438b436716ed21432b809a21024f54caebab887/tokio/src/sync/batch_semaphore.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:4 | impl Semaphore {
/// The maximum number of permits which a semaphore can hold.
///
/// Note that this reserves three bits of flags in the permit counter, but
/// we only actually use one of them. However, the previous semaphore
/// implementation used three bits, so we will continue to reserve them ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 2438b436716ed21432b809a21024f54caebab887 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2438b436716ed21432b809a21024f54caebab887/tokio/src/sync/batch_semaphore.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:14 | }
}
impl fmt::Debug for Semaphore {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Semaphore")
.field("permits", &self.available_permits())
.finish()
}
}
impl Waiter {
fn new(
num_permits: usize,
#[cfg(all(tokio_unstable, feat... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 0fbde0e94b06536917b6686e996856a33aeb29ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0fbde0e94b06536917b6686e996856a33aeb29ee/tokio/src/sync/batch_semaphore.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:15 | target: "runtime::resource::async_op::state_update",
permits_obtained = assign,
permits.op = "add",
);
});
return next == 0;
}
Err(actual) => curr = actual,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 0fbde0e94b06536917b6686e996856a33aeb29ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0fbde0e94b06536917b6686e996856a33aeb29ee/tokio/src/sync/batch_semaphore.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:16 | }
Poll::Ready(r) => {
coop.made_progress();
r?;
*queued = false;
Poll::Ready(Ok(()))
}
};
#[cfg(all(tokio_unstable, feature = "tracing"))]
return trace_poll_op!("poll_acquire", result);
#[cfg(not(al... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 0fbde0e94b06536917b6686e996856a33aeb29ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0fbde0e94b06536917b6686e996856a33aeb29ee/tokio/src/sync/batch_semaphore.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:17 | permits_obtained = 0usize,
permits.op = "override",
);
tracing::trace_span!("runtime.resource.async_op.poll")
});
let ctx = trace::AsyncOpTracingCtx {
async_op_span,
async_op_poll_span,
resource... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 0fbde0e94b06536917b6686e996856a33aeb29ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0fbde0e94b06536917b6686e996856a33aeb29ee/tokio/src/sync/batch_semaphore.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:18 | }
impl Drop for Acquire<'_> {
fn drop(&mut self) {
// If the future is completed, there is no node in the wait list, so we
// can skip acquiring the lock.
if !self.queued {
return;
}
// This is where we ensure safety. The future is being dropped,
// whic... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 0fbde0e94b06536917b6686e996856a33aeb29ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0fbde0e94b06536917b6686e996856a33aeb29ee/tokio/src/sync/batch_semaphore.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:19 | }
impl fmt::Display for AcquireError {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(fmt, "semaphore closed")
}
}
impl std::error::Error for AcquireError {}
// ===== impl TryAcquireError =====
impl TryAcquireError {
/// Returns `true` if the error was caused by a closed sem... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 0fbde0e94b06536917b6686e996856a33aeb29ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0fbde0e94b06536917b6686e996856a33aeb29ee/tokio/src/sync/batch_semaphore.rs | 721 | 777 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:20 | /// `Waiter` is forced to be !Unpin.
unsafe impl linked_list::Link for Waiter {
type Handle = NonNull<Waiter>;
type Target = Waiter;
fn as_raw(handle: &Self::Handle) -> NonNull<Waiter> {
*handle
}
unsafe fn from_raw(ptr: NonNull<Waiter>) -> NonNull<Waiter> {
ptr
}
unsafe f... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 0fbde0e94b06536917b6686e996856a33aeb29ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0fbde0e94b06536917b6686e996856a33aeb29ee/tokio/src/sync/batch_semaphore.rs | 761 | 777 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:9 | // If we assigned permits to all the waiters in the queue, and there are
// still permits left over, assign them back to the semaphore.
break 'inner;
}
};
let mut waiter = waiters.queue.pop_back().unwrap();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5/tokio/src/sync/batch_semaphore.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:10 | }
drop(waiters); // release the lock
wakers.wake_all();
}
assert_eq!(rem, 0);
}
fn poll_acquire(
&self,
cx: &mut Context<'_>,
num_permits: usize,
node: Pin<&mut Waiter>,
queued: bool,
) -> Poll<Result<(), AcquireError>> {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5/tokio/src/sync/batch_semaphore.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:11 | let next = curr - (needed - acquired);
(next, needed >> Self::PERMIT_SHIFT)
} else {
remaining = (needed - acquired) - curr;
(0, curr >> Self::PERMIT_SHIFT)
};
if remaining > 0 && lock.is_none() {
// No permits were imm... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5/tokio/src/sync/batch_semaphore.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:12 | }
}
break lock.expect("lock must be acquired before waiting");
}
Err(actual) => curr = actual,
}
};
if waiters.closed {
return Poll::Ready(Err(AcquireError::closed()));
}
#[cfg(all(tokio_uns... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5/tokio/src/sync/batch_semaphore.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:13 | });
// If the waiter is not already in the wait queue, enqueue it.
if !queued {
let node = unsafe {
let node = Pin::into_inner_unchecked(node) as *mut _;
NonNull::new_unchecked(node)
};
waiters.queue.push_front(node);
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5/tokio/src/sync/batch_semaphore.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:14 | /// Assign permits to the waiter.
///
/// Returns `true` if the waiter should be removed from the queue
fn assign_permits(&self, n: &mut usize) -> bool {
let mut curr = self.state.load(Acquire);
loop {
let assign = cmp::min(curr, *n);
let next = curr - assign;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5/tokio/src/sync/batch_semaphore.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:15 | // First, ensure the current task has enough budget to proceed.
#[cfg(all(tokio_unstable, feature = "tracing"))]
let coop = ready!(trace_poll_op!(
"poll_acquire",
crate::runtime::coop::poll_proceed(cx),
));
#[cfg(not(all(tokio_unstable, feature = "tracing")))]
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5/tokio/src/sync/batch_semaphore.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:16 | };
#[cfg(all(tokio_unstable, feature = "tracing"))]
return semaphore.resource_span.in_scope(|| {
let async_op_span =
tracing::trace_span!("runtime.resource.async_op", source = "Acquire::new");
let async_op_poll_span = async_op_span.in_scope(|| {
t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5/tokio/src/sync/batch_semaphore.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:17 | // Safety: all fields other than `node` are `Unpin`
is_unpin::<&Semaphore>();
is_unpin::<&mut bool>();
is_unpin::<usize>();
let this = self.get_unchecked_mut();
(
Pin::new_unchecked(&mut this.node),
this.semaphore,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5/tokio/src/sync/batch_semaphore.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:18 | }
// Safety: the `Acquire` future is not `Sync` automatically because it contains
// a `Waiter`, which, in turn, contains an `UnsafeCell`. However, the
// `UnsafeCell` is only accessed when the future is borrowed mutably (either in
// `poll` or in `drop`). Therefore, it is safe (although not particularly
// _useful_) ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5/tokio/src/sync/batch_semaphore.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:19 | }
impl fmt::Display for TryAcquireError {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
TryAcquireError::Closed => write!(fmt, "semaphore closed"),
TryAcquireError::NoPermits => write!(fmt, "no permits available"),
}
}
}
impl std::error::Erro... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7c606ab44aa9f0c33dfcf5bc8678411dddeaa9e5/tokio/src/sync/batch_semaphore.rs | 721 | 752 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:2 | }
struct Waitlist {
queue: LinkedList<Waiter, <Waiter as linked_list::Link>::Target>,
closed: bool,
}
/// Error returned from the [`Semaphore::try_acquire`] function.
///
/// [`Semaphore::try_acquire`]: crate::sync::Semaphore::try_acquire
#[derive(Debug, PartialEq, Eq)]
pub enum TryAcquireError {
/// The ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/batch_semaphore.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:7 | pub(crate) fn close(&self) {
let mut waiters = self.waiters.lock();
// If the semaphore's permits counter has enough permits for an
// unqueued waiter to acquire all the permits it needs immediately,
// it won't touch the wait list. Therefore, we have to set a bit on
// the permi... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/batch_semaphore.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:8 | return Err(TryAcquireError::NoPermits);
}
let next = curr - num_permits;
match self.permits.compare_exchange(curr, next, AcqRel, Acquire) {
Ok(_) => {
// TODO: Instrument once issue has been solved
return Ok(());
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/batch_semaphore.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:9 | // If we assigned permits to all the waiters in the queue, and there are
// still permits left over, assign them back to the semaphore.
break 'inner;
}
};
let mut waiter = waiters.queue.pop_back().unwrap();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/batch_semaphore.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:10 | }
drop(waiters); // release the lock
wakers.wake_all();
}
assert_eq!(rem, 0);
}
fn poll_acquire(
&self,
cx: &mut Context<'_>,
num_permits: u32,
node: Pin<&mut Waiter>,
queued: bool,
) -> Poll<Result<(), AcquireError>> {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/batch_semaphore.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:13 | });
// If the waiter is not already in the wait queue, enqueue it.
if !queued {
let node = unsafe {
let node = Pin::into_inner_unchecked(node) as *mut _;
NonNull::new_unchecked(node)
};
waiters.queue.push_front(node);
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/batch_semaphore.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:15 | // First, ensure the current task has enough budget to proceed.
#[cfg(all(tokio_unstable, feature = "tracing"))]
let coop = ready!(trace_poll_op!(
"poll_acquire",
crate::runtime::coop::poll_proceed(cx),
));
#[cfg(not(all(tokio_unstable, feature = "tracing")))]
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/batch_semaphore.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:16 | };
#[cfg(all(tokio_unstable, feature = "tracing"))]
return semaphore.resource_span.in_scope(|| {
let async_op_span =
tracing::trace_span!("runtime.resource.async_op", source = "Acquire::new");
let async_op_poll_span = async_op_span.in_scope(|| {
t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/batch_semaphore.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:17 | // Safety: all fields other than `node` are `Unpin`
is_unpin::<&Semaphore>();
is_unpin::<&mut bool>();
is_unpin::<u32>();
let this = self.get_unchecked_mut();
(
Pin::new_unchecked(&mut this.node),
this.semaphore,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/sync/batch_semaphore.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:12 | }
}
break lock.expect("lock must be acquired before waiting");
}
Err(actual) => curr = actual,
}
};
if waiters.closed {
return Poll::Ready(Err(AcquireError::closed()));
}
#[cfg(all(tokio_uns... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94/tokio/src/sync/batch_semaphore.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:13 | }
});
// If the waiter is not already in the wait queue, enqueue it.
if !queued {
let node = unsafe {
let node = Pin::into_inner_unchecked(node) as *mut _;
NonNull::new_unchecked(node)
};
waiters.queue.push_front(node);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94/tokio/src/sync/batch_semaphore.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:14 | }
/// Assign permits to the waiter.
///
/// Returns `true` if the waiter should be removed from the queue
fn assign_permits(&self, n: &mut usize) -> bool {
let mut curr = self.state.load(Acquire);
loop {
let assign = cmp::min(curr, *n);
let next = curr - assign;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94/tokio/src/sync/batch_semaphore.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:15 | let (node, semaphore, needed, queued) = self.project();
// First, ensure the current task has enough budget to proceed.
#[cfg(all(tokio_unstable, feature = "tracing"))]
let coop = ready!(trace_poll_op!(
"poll_acquire",
crate::runtime::coop::poll_proceed(cx),
));
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94/tokio/src/sync/batch_semaphore.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:16 | queued: false,
};
#[cfg(all(tokio_unstable, feature = "tracing"))]
return semaphore.resource_span.in_scope(|| {
let async_op_span =
tracing::trace_span!("runtime.resource.async_op", source = "Acquire::new");
let async_op_poll_span = async_op_span.in_scope... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94/tokio/src/sync/batch_semaphore.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:17 | unsafe {
// Safety: all fields other than `node` are `Unpin`
is_unpin::<&Semaphore>();
is_unpin::<&mut bool>();
is_unpin::<u32>();
let this = self.get_unchecked_mut();
(
Pin::new_unchecked(&mut this.node),
this.sem... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94/tokio/src/sync/batch_semaphore.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:18 | }
}
// Safety: the `Acquire` future is not `Sync` automatically because it contains
// a `Waiter`, which, in turn, contains an `UnsafeCell`. However, the
// `UnsafeCell` is only accessed when the future is borrowed mutably (either in
// `poll` or in `drop`). Therefore, it is safe (although not particularly
// _useful_... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94/tokio/src/sync/batch_semaphore.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:19 | }
}
impl fmt::Display for TryAcquireError {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
TryAcquireError::Closed => write!(fmt, "semaphore closed"),
TryAcquireError::NoPermits => write!(fmt, "no permits available"),
}
}
}
impl std::error::Er... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/707fb4d0df72d7ee6a4f4b5a675f84cd1863bc94/tokio/src/sync/batch_semaphore.rs | 721 | 753 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:1 | #![cfg_attr(not(feature = "sync"), allow(unreachable_pub, dead_code))]
//! # Implementation Details.
//!
//! The semaphore is implemented using an intrusive linked list of waiters. An
//! atomic counter tracks the number of available permits. If the semaphore does
//! not contain the required number of permits, the tas... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 8955ed5f8525d3585d99e762452978edb69a73ad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8955ed5f8525d3585d99e762452978edb69a73ad/tokio/src/sync/batch_semaphore.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:2 | resource_span: tracing::Span,
}
struct Waitlist {
queue: LinkedList<Waiter, <Waiter as linked_list::Link>::Target>,
closed: bool,
}
/// Error returned from the [`Semaphore::try_acquire`] function.
///
/// [`Semaphore::try_acquire`]: crate::sync::Semaphore::try_acquire
#[derive(Debug, PartialEq, Eq)]
pub enum ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 8955ed5f8525d3585d99e762452978edb69a73ad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8955ed5f8525d3585d99e762452978edb69a73ad/tokio/src/sync/batch_semaphore.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:3 | /// The current state of the waiter.
///
/// This is either the number of remaining permits required by
/// the waiter, or a flag indicating that the waiter is not yet queued.
state: AtomicUsize,
/// The waker to notify the task awaiting permits.
///
/// # Safety
///
/// This may on... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 8955ed5f8525d3585d99e762452978edb69a73ad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8955ed5f8525d3585d99e762452978edb69a73ad/tokio/src/sync/batch_semaphore.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:4 | }
impl Semaphore {
/// The maximum number of permits which a semaphore can hold.
///
/// Note that this reserves three bits of flags in the permit counter, but
/// we only actually use one of them. However, the previous semaphore
/// implementation used three bits, so we will continue to reserve th... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 8955ed5f8525d3585d99e762452978edb69a73ad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8955ed5f8525d3585d99e762452978edb69a73ad/tokio/src/sync/batch_semaphore.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:7 | /// permits and notifies all pending waiters.
pub(crate) fn close(&self) {
let mut waiters = self.waiters.lock();
// If the semaphore's permits counter has enough permits for an
// unqueued waiter to acquire all the permits it needs immediately,
// it won't touch the wait list. There... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 8955ed5f8525d3585d99e762452978edb69a73ad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8955ed5f8525d3585d99e762452978edb69a73ad/tokio/src/sync/batch_semaphore.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:8 | if curr < num_permits {
return Err(TryAcquireError::NoPermits);
}
let next = curr - num_permits;
match self.permits.compare_exchange(curr, next, AcqRel, Acquire) {
Ok(_) => {
// TODO: Instrument once issue has been solved
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 8955ed5f8525d3585d99e762452978edb69a73ad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8955ed5f8525d3585d99e762452978edb69a73ad/tokio/src/sync/batch_semaphore.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:9 | is_empty = true;
// If we assigned permits to all the waiters in the queue, and there are
// still permits left over, assign them back to the semaphore.
break 'inner;
}
};
let mut waiter = waiters... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 8955ed5f8525d3585d99e762452978edb69a73ad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8955ed5f8525d3585d99e762452978edb69a73ad/tokio/src/sync/batch_semaphore.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:10 | rem = 0;
}
drop(waiters); // release the lock
wakers.wake_all();
}
assert_eq!(rem, 0);
}
fn poll_acquire(
&self,
cx: &mut Context<'_>,
num_permits: u32,
node: Pin<&mut Waiter>,
queued: bool,
) -> Poll<Result<(), ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 8955ed5f8525d3585d99e762452978edb69a73ad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8955ed5f8525d3585d99e762452978edb69a73ad/tokio/src/sync/batch_semaphore.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:11 | let (next, acq) = if total >= needed {
let next = curr - (needed - acquired);
(next, needed >> Self::PERMIT_SHIFT)
} else {
remaining = (needed - acquired) - curr;
(0, curr >> Self::PERMIT_SHIFT)
};
if remaining > 0 && ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 8955ed5f8525d3585d99e762452978edb69a73ad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8955ed5f8525d3585d99e762452978edb69a73ad/tokio/src/sync/batch_semaphore.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:12 | break self.waiters.lock();
}
}
break lock.expect("lock must be acquired before waiting");
}
Err(actual) => curr = actual,
}
};
if waiters.closed {
return Ready(Err(AcquireError::close... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 8955ed5f8525d3585d99e762452978edb69a73ad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8955ed5f8525d3585d99e762452978edb69a73ad/tokio/src/sync/batch_semaphore.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/sync/batch_semaphore.rs:13 | old_waker = std::mem::replace(waker, Some(cx.waker().clone()));
}
});
// If the waiter is not already in the wait queue, enqueue it.
if !queued {
let node = unsafe {
let node = Pin::into_inner_unchecked(node) as *mut _;
NonNull::new_unchec... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/sync/batch_semaphore.rs | MIT | 8955ed5f8525d3585d99e762452978edb69a73ad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8955ed5f8525d3585d99e762452978edb69a73ad/tokio/src/sync/batch_semaphore.rs | 481 | 540 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.