mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-07 00:00:09 +02:00
task: quickly send task to heap on debug mode (#4009)
This commit is contained in:
@@ -127,7 +127,13 @@ cfg_rt! {
|
||||
T: Future + Send + 'static,
|
||||
T::Output: Send + 'static,
|
||||
{
|
||||
spawn_inner(future, None)
|
||||
// preventing stack overflows on debug mode, by quickly sending the
|
||||
// task to the heap.
|
||||
if cfg!(debug_assertions) && std::mem::size_of::<T>() > 2048 {
|
||||
spawn_inner(Box::pin(future), None)
|
||||
} else {
|
||||
spawn_inner(future, None)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(tokio_track_caller, track_caller)]
|
||||
|
||||
Reference in New Issue
Block a user