@@ -10,7 +10,7 @@ mod update_output;
10
10
11
11
use std:: {
12
12
fmt:: { Debug , Formatter } ,
13
- mem:: { take , transmute} ,
13
+ mem:: transmute,
14
14
} ;
15
15
16
16
use serde:: { Deserialize , Serialize } ;
@@ -45,25 +45,6 @@ enum TransactionState<'a, 'tx, B: BackingStorage> {
45
45
Owned ( Option < B :: ReadTransaction < ' tx > > ) ,
46
46
}
47
47
48
- impl < ' a , ' tx1 , B : BackingStorage > TransactionState < ' a , ' tx1 , B > {
49
- fn borrow < ' l , ' tx2 > ( & ' l self ) -> TransactionState < ' l , ' tx2 , B >
50
- where
51
- ' a : ' l ,
52
- ' tx1 : ' a + ' tx2 ,
53
- ' tx2 : ' l ,
54
- {
55
- match self {
56
- TransactionState :: None => TransactionState :: None ,
57
- TransactionState :: Borrowed ( tx) => {
58
- TransactionState :: Borrowed ( tx. map ( B :: lower_read_transaction) )
59
- }
60
- TransactionState :: Owned ( tx) => {
61
- TransactionState :: Borrowed ( tx. as_ref ( ) . map ( B :: lower_read_transaction) )
62
- }
63
- }
64
- }
65
- }
66
-
67
48
pub trait ExecuteContext < ' e > : Sized {
68
49
fn session_id ( & self ) -> SessionId ;
69
50
fn task ( & mut self , task_id : TaskId , category : TaskDataCategory ) -> impl TaskGuard + ' e ;
@@ -79,30 +60,18 @@ pub trait ExecuteContext<'e>: Sized {
79
60
where
80
61
T : Clone + Into < AnyOperation > ;
81
62
fn suspending_requested ( & self ) -> bool ;
82
- type Backend ;
83
- fn run_operation (
84
- & mut self ,
85
- parent_op_ref : & mut impl Operation ,
86
- run : impl FnOnce ( & mut ExecuteContextImpl < ' _ , ' _ , Self :: Backend > ) ,
87
- ) ;
88
63
fn get_task_desc_fn ( & self , task_id : TaskId ) -> impl Fn ( ) -> String + Send + Sync + ' static ;
89
64
fn get_task_description ( & self , task_id : TaskId ) -> String ;
90
65
fn should_track_children ( & self ) -> bool ;
91
66
fn should_track_dependencies ( & self ) -> bool ;
92
67
fn should_track_activeness ( & self ) -> bool ;
93
68
}
94
69
95
- pub struct ParentRef < ' a > {
96
- op : & ' a AnyOperation ,
97
- parent : & ' a Option < ParentRef < ' a > > ,
98
- }
99
-
100
70
pub struct ExecuteContextImpl < ' e , ' tx , B : BackingStorage >
101
71
where
102
72
Self : ' e ,
103
73
' tx : ' e ,
104
74
{
105
- parent : Option < ParentRef < ' e > > ,
106
75
backend : & ' e TurboTasksBackendInner < B > ,
107
76
turbo_tasks : & ' e dyn TurboTasksBackendApi < TurboTasksBackend < B > > ,
108
77
_operation_guard : Option < OperationGuard < ' e , B > > ,
121
90
backend,
122
91
turbo_tasks,
123
92
_operation_guard : Some ( backend. start_operation ( ) ) ,
124
- parent : None ,
125
93
transaction : TransactionState :: None ,
126
94
}
127
95
}
@@ -135,7 +103,6 @@ where
135
103
backend,
136
104
turbo_tasks,
137
105
_operation_guard : Some ( backend. start_operation ( ) ) ,
138
- parent : None ,
139
106
transaction : TransactionState :: Borrowed ( transaction) ,
140
107
}
141
108
}
@@ -292,65 +259,13 @@ where
292
259
}
293
260
294
261
fn operation_suspend_point < T : Clone + Into < AnyOperation > > ( & mut self , op : & T ) {
295
- if self . parent . is_some ( ) {
296
- self . backend . operation_suspend_point ( || {
297
- let mut nested = Vec :: new ( ) ;
298
- nested. push ( op. clone ( ) . into ( ) ) ;
299
- let mut cur = self . parent . as_ref ( ) ;
300
- while let Some ( ParentRef { op, parent } ) = cur {
301
- nested. push ( ( * op) . clone ( ) ) ;
302
- cur = parent. as_ref ( ) ;
303
- }
304
- AnyOperation :: Nested ( nested)
305
- } ) ;
306
- } else {
307
- self . backend . operation_suspend_point ( || op. clone ( ) . into ( ) ) ;
308
- }
262
+ self . backend . operation_suspend_point ( || op. clone ( ) . into ( ) ) ;
309
263
}
310
264
311
265
fn suspending_requested ( & self ) -> bool {
312
266
self . backend . suspending_requested ( )
313
267
}
314
268
315
- type Backend = B ;
316
-
317
- fn run_operation (
318
- & mut self ,
319
- parent_op_ref : & mut impl Operation ,
320
- run : impl FnOnce ( & mut ExecuteContextImpl < ' _ , ' _ , B > ) ,
321
- ) {
322
- let parent_op = take ( parent_op_ref) ;
323
- let parent_op: AnyOperation = parent_op. into ( ) ;
324
- let this = & * self ;
325
- fn run_with_inner_ctx < ' a , B : BackingStorage > (
326
- backend : & ' a TurboTasksBackendInner < B > ,
327
- turbo_tasks : & ' a dyn TurboTasksBackendApi < TurboTasksBackend < B > > ,
328
- parent : ParentRef < ' a > ,
329
- transaction : TransactionState < ' a , ' _ , B > ,
330
- run : impl FnOnce ( & mut ExecuteContextImpl < ' _ , ' _ , B > ) ,
331
- ) {
332
- let mut inner_ctx: ExecuteContextImpl < ' _ , ' _ , B > = ExecuteContextImpl {
333
- backend,
334
- turbo_tasks,
335
- _operation_guard : None ,
336
- parent : Some ( parent) ,
337
- transaction,
338
- } ;
339
- run ( & mut inner_ctx) ;
340
- }
341
- run_with_inner_ctx (
342
- self . backend ,
343
- self . turbo_tasks ,
344
- ParentRef {
345
- op : & parent_op,
346
- parent : & this. parent ,
347
- } ,
348
- self . transaction . borrow ( ) ,
349
- run,
350
- ) ;
351
- * parent_op_ref = parent_op. try_into ( ) . unwrap ( ) ;
352
- }
353
-
354
269
fn get_task_desc_fn ( & self , task_id : TaskId ) -> impl Fn ( ) -> String + Send + Sync + ' static {
355
270
self . backend . get_task_desc_fn ( task_id)
356
271
}
0 commit comments