Skip to content

Commit

Permalink
fix the issue with function visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
maminrayej committed Jan 21, 2025
1 parent d78e2a5 commit 274caa1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tokio/src/coop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ fn with_budget<R>(budget: Budget, f: impl FnOnce() -> R) -> R {
f()
}

cfg_rt! {
cfg_pub_if_rt! {
/// Returns `true` if there is still budget left on the task.
///
/// Futures created by the tokio library functions are budget-aware and yield when there is no more
Expand Down Expand Up @@ -191,7 +191,7 @@ cfg_rt! {
/// # }
///```
#[inline(always)]
pub fn has_budget_remaining() -> bool {
fn has_budget_remaining() -> bool {
// If the current budget cannot be accessed due to the thread-local being
// shutdown, then we assume there is budget remaining.
context::budget(|cell| cell.get().has_remaining()).unwrap_or(true)
Expand Down
14 changes: 14 additions & 0 deletions tokio/src/macros/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,20 @@ macro_rules! cfg_not_coop {
}
}

macro_rules! cfg_pub_if_rt {
($($(#[$meta:meta])* fn $($inner:tt)*)*) => {
$(
$(#[$meta])*
#[cfg(feature = "rt")]
pub fn $($inner)*

$(#[$meta])*
#[cfg(not(feature = "rt"))]
pub(crate) fn $($inner)*
)*
}
}

macro_rules! cfg_has_atomic_u64 {
($($item:item)*) => {
$(
Expand Down

0 comments on commit 274caa1

Please sign in to comment.