1
1
use std:: {
2
- any:: Any ,
3
2
future:: Future ,
4
3
hash:: BuildHasherDefault ,
5
4
mem:: take,
@@ -259,54 +258,13 @@ pub trait TurboTasksBackendApi<B: Backend + 'static>: TurboTasksCallApi + Sync +
259
258
/// Returns the duration from the start of the program to the given instant.
260
259
fn program_duration_until ( & self , instant : Instant ) -> Duration ;
261
260
262
- /// An untyped object-safe version of [`TurboTasksBackendApiExt::read_task_state`]. Callers
263
- /// should prefer the extension trait's version of this method.
264
- fn read_task_state_dyn ( & self , func : & mut dyn FnMut ( & B :: TaskState ) ) ;
265
-
266
- /// An untyped object-safe version of [`TurboTasksBackendApiExt::write_task_state`]. Callers
267
- /// should prefer the extension trait's version of this method.
268
- fn write_task_state_dyn ( & self , func : & mut dyn FnMut ( & mut B :: TaskState ) ) ;
269
-
270
261
/// Returns true if the system is idle.
271
262
fn is_idle ( & self ) -> bool ;
272
263
273
264
/// Returns a reference to the backend.
274
265
fn backend ( & self ) -> & B ;
275
266
}
276
267
277
- /// An extension trait for methods of [`TurboTasksBackendApi`] that are not object-safe. This is
278
- /// automatically implemented for all [`TurboTasksBackendApi`]s using a blanket impl.
279
- pub trait TurboTasksBackendApiExt < B : Backend + ' static > : TurboTasksBackendApi < B > {
280
- /// Allows modification of the [`Backend::TaskState`].
281
- ///
282
- /// This function holds open a non-exclusive read lock that blocks writes, so `func` is expected
283
- /// to execute quickly in order to release the lock.
284
- fn read_task_state < T > ( & self , func : impl FnOnce ( & B :: TaskState ) -> T ) -> T {
285
- let mut func = Some ( func) ;
286
- let mut out = None ;
287
- self . read_task_state_dyn ( & mut |ts| out = Some ( ( func. take ( ) . unwrap ( ) ) ( ts) ) ) ;
288
- out. expect ( "read_task_state_dyn must call `func`" )
289
- }
290
-
291
- /// Allows modification of the [`Backend::TaskState`].
292
- ///
293
- /// This function holds open a write lock, so `func` is expected to execute quickly in order to
294
- /// release the lock.
295
- fn write_task_state < T > ( & self , func : impl FnOnce ( & mut B :: TaskState ) -> T ) -> T {
296
- let mut func = Some ( func) ;
297
- let mut out = None ;
298
- self . write_task_state_dyn ( & mut |ts| out = Some ( ( func. take ( ) . unwrap ( ) ) ( ts) ) ) ;
299
- out. expect ( "write_task_state_dyn must call `func`" )
300
- }
301
- }
302
-
303
- impl < TT , B > TurboTasksBackendApiExt < B > for TT
304
- where
305
- TT : TurboTasksBackendApi < B > + ?Sized ,
306
- B : Backend + ' static ,
307
- {
308
- }
309
-
310
268
#[ allow( clippy:: manual_non_exhaustive) ]
311
269
pub struct UpdateInfo {
312
270
pub duration : Duration ,
@@ -405,16 +363,10 @@ struct CurrentTaskState {
405
363
/// Tracks currently running local tasks, and defers cleanup of the global task until those
406
364
/// complete. Also used by `detached_for_testing`.
407
365
local_task_tracker : TaskTracker ,
408
-
409
- backend_state : Box < dyn Any + Send + Sync > ,
410
366
}
411
367
412
368
impl CurrentTaskState {
413
- fn new (
414
- task_id : TaskId ,
415
- execution_id : ExecutionId ,
416
- backend_state : Box < dyn Any + Send + Sync > ,
417
- ) -> Self {
369
+ fn new ( task_id : TaskId , execution_id : ExecutionId ) -> Self {
418
370
Self {
419
371
task_id,
420
372
execution_id,
@@ -423,7 +375,6 @@ impl CurrentTaskState {
423
375
cell_counters : Some ( AutoMap :: default ( ) ) ,
424
376
local_tasks : Vec :: new ( ) ,
425
377
local_task_tracker : TaskTracker :: new ( ) ,
426
- backend_state,
427
378
}
428
379
}
429
380
@@ -685,14 +636,10 @@ impl<B: Backend + 'static> TurboTasks<B> {
685
636
let future = async move {
686
637
let mut schedule_again = true ;
687
638
while schedule_again {
688
- let backend_state = this. backend . new_task_state ( task_id) ;
689
639
// it's okay for execution ids to overflow and wrap, they're just used for an assert
690
640
let execution_id = this. execution_id_factory . wrapping_get ( ) ;
691
- let current_task_state = Arc :: new ( RwLock :: new ( CurrentTaskState :: new (
692
- task_id,
693
- execution_id,
694
- Box :: new ( backend_state) ,
695
- ) ) ) ;
641
+ let current_task_state =
642
+ Arc :: new ( RwLock :: new ( CurrentTaskState :: new ( task_id, execution_id) ) ) ;
696
643
let single_execution_future = async {
697
644
if this. stopped . load ( Ordering :: Acquire ) {
698
645
this. backend . task_execution_canceled ( task_id, & * this) ;
@@ -1454,16 +1401,6 @@ impl<B: Backend + 'static> TurboTasksBackendApi<B> for TurboTasks<B> {
1454
1401
unsafe { self . transient_task_id_factory . reuse ( id. into ( ) ) }
1455
1402
}
1456
1403
1457
- fn read_task_state_dyn ( & self , func : & mut dyn FnMut ( & B :: TaskState ) ) {
1458
- CURRENT_TASK_STATE
1459
- . with ( move |ts| func ( ts. read ( ) . unwrap ( ) . backend_state . downcast_ref ( ) . unwrap ( ) ) )
1460
- }
1461
-
1462
- fn write_task_state_dyn ( & self , func : & mut dyn FnMut ( & mut B :: TaskState ) ) {
1463
- CURRENT_TASK_STATE
1464
- . with ( move |ts| func ( ts. write ( ) . unwrap ( ) . backend_state . downcast_mut ( ) . unwrap ( ) ) )
1465
- }
1466
-
1467
1404
fn is_idle ( & self ) -> bool {
1468
1405
self . currently_scheduled_foreground_jobs
1469
1406
. load ( Ordering :: Acquire )
@@ -1581,7 +1518,6 @@ pub fn with_turbo_tasks_for_testing<T>(
1581
1518
Arc :: new ( RwLock :: new ( CurrentTaskState :: new (
1582
1519
current_task,
1583
1520
execution_id,
1584
- Box :: new ( ( ) ) ,
1585
1521
) ) ) ,
1586
1522
f,
1587
1523
) ,
0 commit comments