@@ -439,6 +439,7 @@ impl CurrentGlobalTaskState {
439
439
fn create_local_task (
440
440
& mut self ,
441
441
ty : CachedTaskType ,
442
+ // if this is a `CachedTaskType::Resolve*`, we'll spawn another task with this persistence
442
443
persistence : TaskPersistence ,
443
444
) -> LocalTaskId {
444
445
self . local_tasks
@@ -475,7 +476,7 @@ struct CurrentLocalTaskState {
475
476
local_task_id : Option < LocalTaskId > ,
476
477
477
478
/// A unique identifier created for each unique[`CurrentLocalTaskState`]. Used to check that
478
- /// [`CurrentTaskState::local_cells`] are valid for the current [`RawVc::LocalCell`].
479
+ /// [`CurrentTaskState::local_cells`] are valid for the currant [`RawVc::LocalCell`].
479
480
execution_id : ExecutionId ,
480
481
481
482
/// The function's metadata if this is a persistent task. Contains information about arguments
@@ -678,28 +679,32 @@ impl<B: Backend + 'static> TurboTasks<B> {
678
679
if registry:: get_function ( func) . arg_meta . is_resolved ( & * arg) {
679
680
return self . native_call ( func, arg, persistence) ;
680
681
}
682
+ let task_type = CachedTaskType :: ResolveNative {
683
+ fn_type : func,
684
+ this : None ,
685
+ arg,
686
+ } ;
687
+ #[ cfg( feature = "local_resolution" ) ]
688
+ return CURRENT_GLOBAL_TASK_STATE . with ( move |gts| {
689
+ let mut gts_write = gts. write ( ) . unwrap ( ) ;
690
+ let local_task_id = gts_write. create_local_task ( task_type, persistence) ;
691
+ RawVc :: LocalOutput ( gts_write. task_id , local_task_id)
692
+ } ) ;
693
+ #[ cfg( not( feature = "local_resolution" ) ) ]
681
694
match persistence {
682
695
TaskPersistence :: LocalCells => {
683
696
todo ! ( "bgw: local tasks" ) ;
684
697
}
685
698
TaskPersistence :: Transient => {
686
699
RawVc :: TaskOutput ( self . backend . get_or_create_transient_task (
687
- CachedTaskType :: ResolveNative {
688
- fn_type : func,
689
- this : None ,
690
- arg,
691
- } ,
700
+ task_type,
692
701
current_task ( "turbo_function calls" ) ,
693
702
self ,
694
703
) )
695
704
}
696
705
TaskPersistence :: Persistent => {
697
706
RawVc :: TaskOutput ( self . backend . get_or_create_persistent_task (
698
- CachedTaskType :: ResolveNative {
699
- fn_type : func,
700
- this : None ,
701
- arg,
702
- } ,
707
+ task_type,
703
708
current_task ( "turbo_function calls" ) ,
704
709
self ,
705
710
) )
@@ -722,7 +727,14 @@ impl<B: Backend + 'static> TurboTasks<B> {
722
727
this : Some ( this) ,
723
728
arg,
724
729
} ;
725
- match persistence {
730
+ #[ cfg( feature = "local_resolution" ) ]
731
+ return CURRENT_GLOBAL_TASK_STATE . with ( move |gts| {
732
+ let mut gts_write = gts. write ( ) . unwrap ( ) ;
733
+ let local_task_id = gts_write. create_local_task ( task_type, persistence) ;
734
+ RawVc :: LocalOutput ( gts_write. task_id , local_task_id)
735
+ } ) ;
736
+ #[ cfg( not( feature = "local_resolution" ) ) ]
737
+ return match persistence {
726
738
TaskPersistence :: LocalCells => {
727
739
todo ! ( "bgw: local tasks" ) ;
728
740
}
@@ -740,7 +752,7 @@ impl<B: Backend + 'static> TurboTasks<B> {
740
752
self ,
741
753
) )
742
754
}
743
- }
755
+ } ;
744
756
}
745
757
746
758
pub fn trait_call (
@@ -772,7 +784,15 @@ impl<B: Backend + 'static> TurboTasks<B> {
772
784
this,
773
785
arg,
774
786
} ;
775
- match persistence {
787
+
788
+ #[ cfg( feature = "local_resolution" ) ]
789
+ return CURRENT_GLOBAL_TASK_STATE . with ( move |gts| {
790
+ let mut gts_write = gts. write ( ) . unwrap ( ) ;
791
+ let local_task_id = gts_write. create_local_task ( task_type, persistence) ;
792
+ RawVc :: LocalOutput ( gts_write. task_id , local_task_id)
793
+ } ) ;
794
+ #[ cfg( not( feature = "local_resolution" ) ) ]
795
+ return match persistence {
776
796
TaskPersistence :: LocalCells => {
777
797
todo ! ( "bgw: local tasks" ) ;
778
798
}
@@ -790,7 +810,7 @@ impl<B: Backend + 'static> TurboTasks<B> {
790
810
self ,
791
811
) )
792
812
}
793
- }
813
+ } ;
794
814
}
795
815
796
816
#[ track_caller]
@@ -2165,12 +2185,17 @@ pub(crate) fn read_local_cell(
2165
2185
}
2166
2186
2167
2187
pub ( crate ) async fn read_local_output (
2168
- _this : & dyn TurboTasksApi ,
2169
- _task_id : TaskId ,
2170
- _local_output_id : LocalTaskId ,
2171
- _consistency : ReadConsistency ,
2188
+ this : & dyn TurboTasksApi ,
2189
+ parent_task_id : TaskId ,
2190
+ local_task_id : LocalTaskId ,
2191
+ consistency : ReadConsistency ,
2172
2192
) -> Result < RawVc > {
2173
- todo ! ( "bgw: local outputs" ) ;
2193
+ loop {
2194
+ match this. try_read_local_output ( parent_task_id, local_task_id, consistency) ? {
2195
+ Ok ( raw_vc) => return Ok ( raw_vc) ,
2196
+ Err ( event_listener) => event_listener. await ,
2197
+ }
2198
+ }
2174
2199
}
2175
2200
2176
2201
/// Panics if the [`ExecutionId`] does not match the current task's
0 commit comments