@@ -17,7 +17,12 @@ use anyhow::{Result, anyhow};
17
17
use auto_hash_map:: AutoMap ;
18
18
use rustc_hash:: FxHasher ;
19
19
use serde:: { Deserialize , Serialize } ;
20
- use tokio:: { runtime:: Handle , select, sync:: mpsc:: Receiver , task_local} ;
20
+ use tokio:: {
21
+ runtime:: Handle ,
22
+ select,
23
+ sync:: { Semaphore , mpsc:: Receiver } ,
24
+ task_local,
25
+ } ;
21
26
use tokio_util:: task:: TaskTracker ;
22
27
use tracing:: { Instrument , Level , Span , info_span, instrument, trace_span} ;
23
28
use turbo_tasks_malloc:: TurboMalloc ;
@@ -386,6 +391,8 @@ pub struct TurboTasks<B: Backend + 'static> {
386
391
event_background : Event ,
387
392
program_start : Instant ,
388
393
compilation_events : CompilationEventQueue ,
394
+
395
+ semaphore : Semaphore ,
389
396
}
390
397
391
398
/// Information about a non-local task. A non-local task can contain multiple "local" tasks, which
@@ -479,6 +486,8 @@ task_local! {
479
486
static CURRENT_TASK_STATE : Arc <RwLock <CurrentTaskState >>;
480
487
}
481
488
489
+ const MAX_TASK_COUNT : usize = 1024 * 1024 * 256 ;
490
+
482
491
impl < B : Backend + ' static > TurboTasks < B > {
483
492
// TODO better lifetime management for turbo tasks
484
493
// consider using unsafe for the task_local turbo tasks
@@ -512,6 +521,7 @@ impl<B: Backend + 'static> TurboTasks<B> {
512
521
event_background : Event :: new ( || "TurboTasks::event_background" . to_string ( ) ) ,
513
522
program_start : Instant :: now ( ) ,
514
523
compilation_events : CompilationEventQueue :: default ( ) ,
524
+ semaphore : Semaphore :: new ( MAX_TASK_COUNT ) ,
515
525
} ) ;
516
526
this. backend . startup ( & * this) ;
517
527
this
0 commit comments