pub struct TransferQueue {
registry: Arc<RwLock<TransferRegistry>>,
semaphore: RwLock<Arc<Semaphore>>,
}Expand description
Concurrency-capped transfer queue wrapping TransferRegistry.
The [Semaphore] limits how many transfers run simultaneously. The
semaphore is acquired inside the spawned task, so enqueue always
returns immediately with a request_id.
When transfer_concurrency changes in settings, call rebuild_semaphore
to replace the semaphore with a new one at the new width.
Fields§
§registry: Arc<RwLock<TransferRegistry>>§semaphore: RwLock<Arc<Semaphore>>Implementations§
Source§impl TransferQueue
impl TransferQueue
Sourcepub fn registry(&self) -> &RwLock<TransferRegistry>
pub fn registry(&self) -> &RwLock<TransferRegistry>
Shared reference to the inner RwLock<TransferRegistry>.
Sourcepub fn rebuild_semaphore(&self, new_concurrency: u32)
pub fn rebuild_semaphore(&self, new_concurrency: u32)
Replace the semaphore with a new one at new_concurrency.
In-flight transfers hold their old permits until they finish; the new semaphore only affects newly spawned transfers.
Sourcepub fn current_semaphore(&self) -> Arc<Semaphore>
pub fn current_semaphore(&self) -> Arc<Semaphore>
Acquire a clone of the current semaphore.
The returned Arc<Semaphore> is the one that was active at the moment
of the call. Spawned tasks hold this arc; a rebuild_semaphore call
does not invalidate existing permit holders.
Sourcepub fn registry_handle(&self) -> TransferRegistryHandle
pub fn registry_handle(&self) -> TransferRegistryHandle
Return a TransferRegistryHandle that shares the same underlying
registry, suitable for passing to download_object / upload_object.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for TransferQueue
impl !RefUnwindSafe for TransferQueue
impl Send for TransferQueue
impl Sync for TransferQueue
impl Unpin for TransferQueue
impl UnsafeUnpin for TransferQueue
impl !UnwindSafe for TransferQueue
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more