@@ -137,20 +137,13 @@ pub trait TurboTasksApi: TurboTasksCallApi + Sync + Send {
137137 index : CellId ,
138138 ) -> Result < Result < TypedCellContent , EventListener > > ;
139139
140+ /// This does not accept a consistency argument, as you cannot control consistency of a read of
141+ /// an operation owned by your own task. Strongly consistent reads are only allowed on
142+ /// `OperationVc`s, which should never be local tasks.
140143 fn try_read_local_output (
141144 & self ,
142145 parent_task_id : TaskId ,
143146 local_task_id : LocalTaskId ,
144- consistency : ReadConsistency ,
145- ) -> Result < Result < RawVc , EventListener > > ;
146-
147- /// INVALIDATION: Be careful with this, it will not track dependencies, so
148- /// using it could break cache invalidation.
149- fn try_read_local_output_untracked (
150- & self ,
151- parent_task_id : TaskId ,
152- local_task_id : LocalTaskId ,
153- consistency : ReadConsistency ,
154147 ) -> Result < Result < RawVc , EventListener > > ;
155148
156149 fn read_task_collectibles ( & self , task : TaskId , trait_id : TraitTypeId ) -> TaskCollectiblesMap ;
@@ -335,7 +328,7 @@ pub enum TaskPersistence {
335328 LocalCells ,
336329}
337330
338- #[ derive( Clone , Copy , Eq , PartialEq ) ]
331+ #[ derive( Clone , Copy , Debug , Eq , PartialEq ) ]
339332pub enum ReadConsistency {
340333 /// The default behavior for most APIs. Reads are faster, but may return stale values, which
341334 /// may later trigger re-computation.
@@ -1323,26 +1316,16 @@ impl<B: Backend + 'static> TurboTasksApi for TurboTasks<B> {
13231316 & self ,
13241317 parent_task_id : TaskId ,
13251318 local_task_id : LocalTaskId ,
1326- consistency : ReadConsistency ,
1327- ) -> Result < Result < RawVc , EventListener > > {
1328- // we don't currently support reading a local output outside of it's own task, so
1329- // tracked/untracked is currently irrelevant
1330- self . try_read_local_output_untracked ( parent_task_id, local_task_id, consistency)
1331- }
1332-
1333- /// INVALIDATION: Be careful with this, it will not track dependencies, so
1334- /// using it could break cache invalidation.
1335- fn try_read_local_output_untracked (
1336- & self ,
1337- parent_task_id : TaskId ,
1338- local_task_id : LocalTaskId ,
1339- // we don't currently support reading a local output outside of it's own task, so
1340- // consistency is currently irrelevant
1341- _consistency : ReadConsistency ,
13421319 ) -> Result < Result < RawVc , EventListener > > {
13431320 CURRENT_GLOBAL_TASK_STATE . with ( |gts| {
13441321 let gts_read = gts. read ( ) . unwrap ( ) ;
1322+
1323+ // Local Vcs are local to their parent task, and do not exist outside of it. This is
1324+ // weakly enforced at compile time using the `NonLocalValue` marker trait. This
1325+ // assertion exists to handle any potential escapes that the compile-time checks cannot
1326+ // capture.
13451327 gts_read. assert_task_id ( parent_task_id) ;
1328+
13461329 match gts_read. get_local_task ( local_task_id) {
13471330 LocalTask :: Scheduled { done_event } => Ok ( Err ( done_event. listen ( ) ) ) ,
13481331 LocalTask :: Done { output } => Ok ( Ok ( output. as_read_result ( ) ?) ) ,
@@ -2051,10 +2034,9 @@ pub(crate) async fn read_local_output(
20512034 this : & dyn TurboTasksApi ,
20522035 parent_task_id : TaskId ,
20532036 local_task_id : LocalTaskId ,
2054- consistency : ReadConsistency ,
20552037) -> Result < RawVc > {
20562038 loop {
2057- match this. try_read_local_output ( parent_task_id, local_task_id, consistency ) ? {
2039+ match this. try_read_local_output ( parent_task_id, local_task_id) ? {
20582040 Ok ( raw_vc) => return Ok ( raw_vc) ,
20592041 Err ( event_listener) => event_listener. await ,
20602042 }
0 commit comments