@@ -58,15 +58,7 @@ pub trait TurboTasksCallApi: Sync + Send {
5858 fn dynamic_call (
5959 & self ,
6060 func : FunctionId ,
61- arg : Box < dyn MagicAny > ,
62- persistence : TaskPersistence ,
63- ) -> RawVc ;
64- /// Calls a native function with arguments. Resolves arguments when needed
65- /// with a wrapper task.
66- fn dynamic_this_call (
67- & self ,
68- func : FunctionId ,
69- this : RawVc ,
61+ this : Option < RawVc > ,
7062 arg : Box < dyn MagicAny > ,
7163 persistence : TaskPersistence ,
7264 ) -> RawVc ;
@@ -75,15 +67,7 @@ pub trait TurboTasksCallApi: Sync + Send {
7567 fn native_call (
7668 & self ,
7769 func : FunctionId ,
78- arg : Box < dyn MagicAny > ,
79- persistence : TaskPersistence ,
80- ) -> RawVc ;
81- /// Call a native function with arguments.
82- /// All inputs must be resolved.
83- fn this_call (
84- & self ,
85- func : FunctionId ,
86- this : RawVc ,
70+ this : Option < RawVc > ,
8771 arg : Box < dyn MagicAny > ,
8872 persistence : TaskPersistence ,
8973 ) -> RawVc ;
@@ -606,48 +590,12 @@ impl<B: Backend + 'static> TurboTasks<B> {
606590
607591 pub ( crate ) fn native_call (
608592 & self ,
609- func : FunctionId ,
593+ fn_type : FunctionId ,
594+ this : Option < RawVc > ,
610595 arg : Box < dyn MagicAny > ,
611596 persistence : TaskPersistence ,
612597 ) -> RawVc {
613- let task_type = CachedTaskType {
614- fn_type : func,
615- this : None ,
616- arg,
617- } ;
618- match persistence {
619- TaskPersistence :: LocalCells => {
620- todo ! ( "bgw: local tasks" ) ;
621- }
622- TaskPersistence :: Transient => {
623- RawVc :: TaskOutput ( self . backend . get_or_create_transient_task (
624- task_type,
625- current_task ( "turbo_function calls" ) ,
626- self ,
627- ) )
628- }
629- TaskPersistence :: Persistent => {
630- RawVc :: TaskOutput ( self . backend . get_or_create_persistent_task (
631- task_type,
632- current_task ( "turbo_function calls" ) ,
633- self ,
634- ) )
635- }
636- }
637- }
638-
639- pub ( crate ) fn this_call (
640- & self ,
641- func : FunctionId ,
642- this : RawVc ,
643- arg : Box < dyn MagicAny > ,
644- persistence : TaskPersistence ,
645- ) -> RawVc {
646- let task_type = CachedTaskType {
647- fn_type : func,
648- this : Some ( this) ,
649- arg,
650- } ;
598+ let task_type = CachedTaskType { fn_type, this, arg } ;
651599 match persistence {
652600 TaskPersistence :: LocalCells => {
653601 todo ! ( "bgw: local tasks" ) ;
@@ -671,36 +619,17 @@ impl<B: Backend + 'static> TurboTasks<B> {
671619
672620 pub fn dynamic_call (
673621 & self ,
674- func : FunctionId ,
622+ fn_type : FunctionId ,
623+ this : Option < RawVc > ,
675624 arg : Box < dyn MagicAny > ,
676625 persistence : TaskPersistence ,
677626 ) -> RawVc {
678- if registry:: get_function ( func) . arg_meta . is_resolved ( & * arg) {
679- return self . native_call ( func, arg, persistence) ;
680- }
681- let task_type = LocalTaskType :: ResolveNative {
682- fn_type : func,
683- this : None ,
684- arg,
685- } ;
686- self . schedule_local_task ( task_type, persistence)
687- }
688-
689- pub fn dynamic_this_call (
690- & self ,
691- func : FunctionId ,
692- this : RawVc ,
693- arg : Box < dyn MagicAny > ,
694- persistence : TaskPersistence ,
695- ) -> RawVc {
696- if this. is_resolved ( ) && registry:: get_function ( func) . arg_meta . is_resolved ( & * arg) {
697- return self . this_call ( func, this, arg, persistence) ;
627+ if this. is_none_or ( |this| this. is_resolved ( ) )
628+ && registry:: get_function ( fn_type) . arg_meta . is_resolved ( & * arg)
629+ {
630+ return self . native_call ( fn_type, this, arg, persistence) ;
698631 }
699- let task_type = LocalTaskType :: ResolveNative {
700- fn_type : func,
701- this : Some ( this) ,
702- arg,
703- } ;
632+ let task_type = LocalTaskType :: ResolveNative { fn_type, this, arg } ;
704633 self . schedule_local_task ( task_type, persistence)
705634 }
706635
@@ -718,7 +647,7 @@ impl<B: Backend + 'static> TurboTasks<B> {
718647 if let RawVc :: TaskCell ( _, CellId { type_id, .. } ) = this {
719648 match get_trait_method ( trait_type, type_id, trait_fn_name) {
720649 Ok ( native_fn) => {
721- return self . dynamic_this_call ( native_fn, this, arg, persistence) ;
650+ return self . dynamic_call ( native_fn, Some ( this) , arg, persistence) ;
722651 }
723652 Err ( name) => {
724653 trait_fn_name = name;
@@ -1240,36 +1169,20 @@ impl<B: Backend + 'static> TurboTasksCallApi for TurboTasks<B> {
12401169 fn dynamic_call (
12411170 & self ,
12421171 func : FunctionId ,
1172+ this : Option < RawVc > ,
12431173 arg : Box < dyn MagicAny > ,
12441174 persistence : TaskPersistence ,
12451175 ) -> RawVc {
1246- self . dynamic_call ( func, arg, persistence)
1247- }
1248- fn dynamic_this_call (
1249- & self ,
1250- func : FunctionId ,
1251- this : RawVc ,
1252- arg : Box < dyn MagicAny > ,
1253- persistence : TaskPersistence ,
1254- ) -> RawVc {
1255- self . dynamic_this_call ( func, this, arg, persistence)
1176+ self . dynamic_call ( func, this, arg, persistence)
12561177 }
12571178 fn native_call (
12581179 & self ,
12591180 func : FunctionId ,
1181+ this : Option < RawVc > ,
12601182 arg : Box < dyn MagicAny > ,
12611183 persistence : TaskPersistence ,
12621184 ) -> RawVc {
1263- self . native_call ( func, arg, persistence)
1264- }
1265- fn this_call (
1266- & self ,
1267- func : FunctionId ,
1268- this : RawVc ,
1269- arg : Box < dyn MagicAny > ,
1270- persistence : TaskPersistence ,
1271- ) -> RawVc {
1272- self . this_call ( func, this, arg, persistence)
1185+ self . native_call ( func, this, arg, persistence)
12731186 }
12741187 fn trait_call (
12751188 & self ,
@@ -1723,21 +1636,11 @@ pub async fn run_once_with_reason<T: Send + 'static>(
17231636/// Calls [`TurboTasks::dynamic_call`] for the current turbo tasks instance.
17241637pub fn dynamic_call (
17251638 func : FunctionId ,
1639+ this : Option < RawVc > ,
17261640 arg : Box < dyn MagicAny > ,
17271641 persistence : TaskPersistence ,
17281642) -> RawVc {
1729- with_turbo_tasks ( |tt| tt. dynamic_call ( func, arg, persistence) )
1730- }
1731-
1732- /// Calls [`TurboTasks::dynamic_this_call`] for the current turbo tasks
1733- /// instance.
1734- pub fn dynamic_this_call (
1735- func : FunctionId ,
1736- this : RawVc ,
1737- arg : Box < dyn MagicAny > ,
1738- persistence : TaskPersistence ,
1739- ) -> RawVc {
1740- with_turbo_tasks ( |tt| tt. dynamic_this_call ( func, this, arg, persistence) )
1643+ with_turbo_tasks ( |tt| tt. dynamic_call ( func, this, arg, persistence) )
17411644}
17421645
17431646/// Calls [`TurboTasks::trait_call`] for the current turbo tasks instance.
0 commit comments