Skip to content

Commit

Permalink
send big futures to the heap in release mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Noah-Kennedy committed Oct 12, 2024
1 parent 20b4c92 commit bf5e5f9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tokio/src/runtime/local_runtime/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl LocalRuntime {
{
// safety: spawn_local can only be called from `LocalRuntime`, which this is
unsafe {
if cfg!(debug_assertions) && std::mem::size_of::<F>() > BOX_FUTURE_THRESHOLD {
if std::mem::size_of::<F>() > BOX_FUTURE_THRESHOLD {
self.handle.spawn_local_named(Box::pin(future), None)
} else {
self.handle.spawn_local_named(future, None)
Expand Down Expand Up @@ -211,7 +211,7 @@ impl LocalRuntime {
/// ```
#[track_caller]
pub fn block_on<F: Future>(&self, future: F) -> F::Output {
if cfg!(debug_assertions) && std::mem::size_of::<F>() > BOX_FUTURE_THRESHOLD {
if std::mem::size_of::<F>() > BOX_FUTURE_THRESHOLD {
self.block_on_inner(Box::pin(future))
} else {
self.block_on_inner(future)
Expand Down

0 comments on commit bf5e5f9

Please sign in to comment.