diff --git a/actix-utils/src/counter.rs b/actix-utils/src/counter.rs index 51e0afae..a61ef90e 100644 --- a/actix-utils/src/counter.rs +++ b/actix-utils/src/counter.rs @@ -22,16 +22,19 @@ impl Counter { } /// Create new counter guard, incrementing the counter. + #[inline] pub fn get(&self) -> CounterGuard { CounterGuard::new(self.0.clone()) } /// Returns true if counter is below capacity. Otherwise, register to wake task when it is. + #[inline] pub fn available(&self, cx: &mut task::Context<'_>) -> bool { self.0.available(cx) } /// Get total number of acquired guards. + #[inline] pub fn total(&self) -> usize { self.0.count.get() } diff --git a/actix-utils/src/future/either.rs b/actix-utils/src/future/either.rs index 77b2118d..78582954 100644 --- a/actix-utils/src/future/either.rs +++ b/actix-utils/src/future/either.rs @@ -40,11 +40,13 @@ pin_project! { impl Either { /// Creates new `Either` using left variant. + #[inline] pub fn left(value: L) -> Either { Either::Left { value } } /// Creates new `Either` using right variant. + #[inline] pub fn right(value: R) -> Either { Either::Right { value } } @@ -52,6 +54,7 @@ impl Either { impl Either { /// Unwraps into inner value when left and right have a common type. + #[inline] pub fn into_inner(self) -> T { match self { Either::Left { value } => value, @@ -67,6 +70,7 @@ where { type Output = L::Output; + #[inline] fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { match self.project() { EitherProj::Left { value } => value.poll(cx), diff --git a/actix-utils/src/future/poll_fn.rs b/actix-utils/src/future/poll_fn.rs index 5e911bf5..31421b45 100644 --- a/actix-utils/src/future/poll_fn.rs +++ b/actix-utils/src/future/poll_fn.rs @@ -8,6 +8,7 @@ use core::{ }; /// Creates a future driven by the provided function that receives a task context. +#[inline] pub fn poll_fn(f: F) -> PollFn where F: FnMut(&mut Context<'_>) -> Poll, @@ -34,6 +35,7 @@ where { type Output = T; + #[inline] fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { (self.f)(cx) } diff --git a/actix-utils/src/future/ready.rs b/actix-utils/src/future/ready.rs index e35f6574..cd375c1f 100644 --- a/actix-utils/src/future/ready.rs +++ b/actix-utils/src/future/ready.rs @@ -65,6 +65,7 @@ impl Future for Ready { /// let a = ready(1); /// assert_eq!(a.into_inner(), 1); /// ``` +#[inline] pub fn ready(val: T) -> Ready { Ready { val: Some(val) } } @@ -80,6 +81,7 @@ pub fn ready(val: T) -> Ready { /// assert_eq!(a.await, Ok(1)); /// # } /// ``` +#[inline] pub fn ok(val: T) -> Ready> { Ready { val: Some(Ok(val)) } } @@ -95,6 +97,7 @@ pub fn ok(val: T) -> Ready> { /// assert_eq!(a.await, Err(1)); /// # } /// ``` +#[inline] pub fn err(err: E) -> Ready> { Ready { val: Some(Err(err)),