pub struct SemaphoreKey {}
Expand description

The SemaphoreKey struct holds an implementation to be used to for the Semaphore by key functionality.

Implementations§

source§

impl SemaphoreKey

source

pub async fn get_or_create_semaphore( key: &String, allowed_concurrent_threads: usize ) -> Arc<Semaphore>

Gets or creates a semaphore wrapped in an Arc by the provided key

Arguments
  • key - The key to get an existing or create a new semaphore by

  • allowed_concurrent_threads - Used when creating a new semaphore (if an existing one is not found by key), to specify how many concurrent threads are allowed access.

source

pub async fn remove_if_exists(key: &String) -> Option<Arc<Semaphore>>

Removes a semaphore from the internal map if it exists, and returns it wrapped in an Arc

Arguments
  • key - The key to get an existing semaphore by

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.