Unverified Commit 4e4632c2 authored by Benjamin Woodruff's avatar Benjamin Woodruff Committed by GitHub

refactor(turbo-tasks): Add TaskPersistence enum for task creation functions (#68866)

Builds on top of the `is_transient` boolean arguments from #68436, but
uses an enum to provide a third variant of
`TaskPersistence::LocalCells`.

The branches for this are `todo!()` right now, but the idea is that
we'll intercept these in the manager and schedule them inside the
manager instead of creating a unique task with its own `TaskId` on the
backend.

## Testing

Some of the `local_cell` tests are broken with this change, as functions
annotated with `#[turbo_tasks::function(local_cells)]` now hit the
`todo!()` blocks added in this PR. Those tests are disabled for now, and
I'll fix this in a later PR. *(This is okay, nothing is using local
cells yet, aside from those tests)*
parent 2865e182
use std::collections::HashSet; use std::collections::HashSet;
use proc_macro2::{Ident, Span, TokenStream}; use proc_macro2::{Ident, Span, TokenStream};
use quote::{quote, quote_spanned}; use quote::{quote, quote_spanned, ToTokens};
use syn::{ use syn::{
parenthesized, parenthesized,
parse::{Parse, ParseStream}, parse::{Parse, ParseStream},
...@@ -24,6 +24,8 @@ pub struct TurboFn { ...@@ -24,6 +24,8 @@ pub struct TurboFn {
inputs: Vec<Input>, inputs: Vec<Input>,
/// Should we check that the return type contains a `ResolvedValue`? /// Should we check that the return type contains a `ResolvedValue`?
resolved: Option<Span>, resolved: Option<Span>,
/// Should this function use `TaskPersistence::LocalCells`?
local_cells: bool,
} }
#[derive(Debug)] #[derive(Debug)]
...@@ -257,6 +259,7 @@ impl TurboFn { ...@@ -257,6 +259,7 @@ impl TurboFn {
this, this,
inputs, inputs,
resolved: args.resolved, resolved: args.resolved,
local_cells: args.local_cells.is_some(),
}) })
} }
...@@ -301,17 +304,26 @@ impl TurboFn { ...@@ -301,17 +304,26 @@ impl TurboFn {
} }
} }
fn inputs(&self) -> Vec<&Ident> { fn input_idents(&self) -> impl Iterator<Item = &Ident> {
self.inputs self.inputs.iter().map(|Input { ident, .. }| ident)
.iter()
.map(|Input { ident, .. }| ident)
.collect()
} }
pub fn input_types(&self) -> Vec<&Type> { pub fn input_types(&self) -> Vec<&Type> {
self.inputs.iter().map(|Input { ty, .. }| ty).collect() self.inputs.iter().map(|Input { ty, .. }| ty).collect()
} }
pub fn persistence(&self) -> impl ToTokens {
if self.local_cells {
quote! {
turbo_tasks::TaskPersistence::LocalCells
}
} else {
quote! {
turbo_tasks::macro_helpers::get_non_local_persistence_from_inputs(&*inputs)
}
}
}
fn converted_this(&self) -> Option<Expr> { fn converted_this(&self) -> Option<Expr> {
self.this.as_ref().map(|Input { ty: _, ident }| { self.this.as_ref().map(|Input { ty: _, ident }| {
parse_quote! { parse_quote! {
...@@ -344,52 +356,56 @@ impl TurboFn { ...@@ -344,52 +356,56 @@ impl TurboFn {
/// The block of the exposed function for a dynamic dispatch call to the /// The block of the exposed function for a dynamic dispatch call to the
/// given trait. /// given trait.
pub fn dynamic_block(&self, trait_type_id_ident: &Ident) -> Block { pub fn dynamic_block(&self, trait_type_id_ident: &Ident) -> Block {
let Some(converted_this) = self.converted_this() else {
return parse_quote! {
{
unimplemented!("trait methods without self are not yet supported")
}
};
};
let ident = &self.ident; let ident = &self.ident;
let output = &self.output; let output = &self.output;
let assertions = self.get_assertions(); let assertions = self.get_assertions();
if let Some(converted_this) = self.converted_this() { let inputs = self.input_idents();
let inputs = self.inputs(); let persistence = self.persistence();
parse_quote! { parse_quote! {
{ {
#assertions #assertions
let turbo_tasks_transient = #( turbo_tasks::TaskInput::is_transient(&#inputs) ||)* false; let inputs = std::boxed::Box::new((#(#inputs,)*));
let persistence = #persistence;
<#output as turbo_tasks::task::TaskOutput>::try_from_raw_vc( <#output as turbo_tasks::task::TaskOutput>::try_from_raw_vc(
turbo_tasks::trait_call( turbo_tasks::trait_call(
*#trait_type_id_ident, *#trait_type_id_ident,
std::borrow::Cow::Borrowed(stringify!(#ident)), std::borrow::Cow::Borrowed(stringify!(#ident)),
#converted_this, #converted_this,
Box::new((#(#inputs,)*)) as Box<dyn turbo_tasks::MagicAny>, inputs as std::boxed::Box<dyn turbo_tasks::MagicAny>,
turbo_tasks_transient, persistence,
) )
) )
} }
} }
} else {
parse_quote! {
{
unimplemented!("trait methods without self are not yet supported")
}
}
}
} }
/// The block of the exposed function for a static dispatch call to the /// The block of the exposed function for a static dispatch call to the
/// given native function. /// given native function.
pub fn static_block(&self, native_function_id_ident: &Ident) -> Block { pub fn static_block(&self, native_function_id_ident: &Ident) -> Block {
let output = &self.output; let output = &self.output;
let inputs = self.inputs(); let inputs = self.input_idents();
let persistence = self.persistence();
let assertions = self.get_assertions(); let assertions = self.get_assertions();
if let Some(converted_this) = self.converted_this() { if let Some(converted_this) = self.converted_this() {
parse_quote! { parse_quote! {
{ {
#assertions #assertions
let turbo_tasks_transient = #( turbo_tasks::TaskInput::is_transient(&#inputs) ||)* false; let inputs = std::boxed::Box::new((#(#inputs,)*));
let persistence = #persistence;
<#output as turbo_tasks::task::TaskOutput>::try_from_raw_vc( <#output as turbo_tasks::task::TaskOutput>::try_from_raw_vc(
turbo_tasks::dynamic_this_call( turbo_tasks::dynamic_this_call(
*#native_function_id_ident, *#native_function_id_ident,
#converted_this, #converted_this,
Box::new((#(#inputs,)*)) as Box<dyn turbo_tasks::MagicAny>, inputs as std::boxed::Box<dyn turbo_tasks::MagicAny>,
turbo_tasks_transient persistence,
) )
) )
} }
...@@ -398,12 +414,13 @@ impl TurboFn { ...@@ -398,12 +414,13 @@ impl TurboFn {
parse_quote! { parse_quote! {
{ {
#assertions #assertions
let turbo_tasks_transient = #( turbo_tasks::TaskInput::is_transient(&#inputs) ||)* false; let inputs = std::boxed::Box::new((#(#inputs,)*));
let persistence = #persistence;
<#output as turbo_tasks::task::TaskOutput>::try_from_raw_vc( <#output as turbo_tasks::task::TaskOutput>::try_from_raw_vc(
turbo_tasks::dynamic_call( turbo_tasks::dynamic_call(
*#native_function_id_ident, *#native_function_id_ident,
Box::new((#(#inputs,)*)) as Box<dyn turbo_tasks::MagicAny>, inputs as std::boxed::Box<dyn turbo_tasks::MagicAny>,
turbo_tasks_transient, persistence,
) )
) )
} }
......
...@@ -810,7 +810,7 @@ impl Task { ...@@ -810,7 +810,7 @@ impl Task {
native_fn_id, native_fn_id,
*this, *this,
&**arg, &**arg,
self.id.is_transient(), self.id.persistence(),
turbo_tasks, turbo_tasks,
)); ));
drop(entered); drop(entered);
...@@ -833,7 +833,7 @@ impl Task { ...@@ -833,7 +833,7 @@ impl Task {
name, name,
*this, *this,
&**arg, &**arg,
self.id.is_transient(), self.id.persistence(),
turbo_tasks, turbo_tasks,
)); ));
drop(entered); drop(entered);
......
../../turbo-tasks-testing/tests/local_cell.rs
\ No newline at end of file
...@@ -20,8 +20,8 @@ use turbo_tasks::{ ...@@ -20,8 +20,8 @@ use turbo_tasks::{
registry, registry,
test_helpers::with_turbo_tasks_for_testing, test_helpers::with_turbo_tasks_for_testing,
util::{SharedError, StaticOrArc}, util::{SharedError, StaticOrArc},
CellId, ExecutionId, InvalidationReason, MagicAny, RawVc, TaskId, TraitTypeId, TurboTasksApi, CellId, ExecutionId, InvalidationReason, MagicAny, RawVc, TaskId, TaskPersistence, TraitTypeId,
TurboTasksCallApi, TurboTasksApi, TurboTasksCallApi,
}; };
pub use crate::run::{run, run_without_cache_check, Registration}; pub use crate::run::{run, run_without_cache_check, Registration};
...@@ -92,7 +92,7 @@ impl TurboTasksCallApi for VcStorage { ...@@ -92,7 +92,7 @@ impl TurboTasksCallApi for VcStorage {
&self, &self,
func: turbo_tasks::FunctionId, func: turbo_tasks::FunctionId,
arg: Box<dyn MagicAny>, arg: Box<dyn MagicAny>,
_is_transient: bool, _persistence: TaskPersistence,
) -> RawVc { ) -> RawVc {
self.dynamic_call(func, None, arg) self.dynamic_call(func, None, arg)
} }
...@@ -102,7 +102,7 @@ impl TurboTasksCallApi for VcStorage { ...@@ -102,7 +102,7 @@ impl TurboTasksCallApi for VcStorage {
func: turbo_tasks::FunctionId, func: turbo_tasks::FunctionId,
this_arg: RawVc, this_arg: RawVc,
arg: Box<dyn MagicAny>, arg: Box<dyn MagicAny>,
_is_transient: bool, _persistence: TaskPersistence,
) -> RawVc { ) -> RawVc {
self.dynamic_call(func, Some(this_arg), arg) self.dynamic_call(func, Some(this_arg), arg)
} }
...@@ -111,7 +111,7 @@ impl TurboTasksCallApi for VcStorage { ...@@ -111,7 +111,7 @@ impl TurboTasksCallApi for VcStorage {
&self, &self,
_func: turbo_tasks::FunctionId, _func: turbo_tasks::FunctionId,
_arg: Box<dyn MagicAny>, _arg: Box<dyn MagicAny>,
_is_transient: bool, _persistence: TaskPersistence,
) -> RawVc { ) -> RawVc {
unreachable!() unreachable!()
} }
...@@ -121,7 +121,7 @@ impl TurboTasksCallApi for VcStorage { ...@@ -121,7 +121,7 @@ impl TurboTasksCallApi for VcStorage {
_func: turbo_tasks::FunctionId, _func: turbo_tasks::FunctionId,
_this: RawVc, _this: RawVc,
_arg: Box<dyn MagicAny>, _arg: Box<dyn MagicAny>,
_is_transient: bool, _persistence: TaskPersistence,
) -> RawVc { ) -> RawVc {
unreachable!() unreachable!()
} }
...@@ -132,7 +132,7 @@ impl TurboTasksCallApi for VcStorage { ...@@ -132,7 +132,7 @@ impl TurboTasksCallApi for VcStorage {
_trait_fn_name: Cow<'static, str>, _trait_fn_name: Cow<'static, str>,
_this: RawVc, _this: RawVc,
_arg: Box<dyn MagicAny>, _arg: Box<dyn MagicAny>,
_is_transient: bool, _persistence: TaskPersistence,
) -> RawVc { ) -> RawVc {
unreachable!() unreachable!()
} }
......
#![feature(arbitrary_self_types)] #![feature(arbitrary_self_types)]
use anyhow::Result;
use turbo_tasks::{ use turbo_tasks::{
debug::ValueDebug, test_helpers::current_task_for_testing, ResolvedValue, ValueDefault, Vc, debug::ValueDebug, test_helpers::current_task_for_testing, ResolvedValue, ValueDefault, Vc,
}; };
...@@ -14,8 +15,8 @@ struct Wrapper(u32); ...@@ -14,8 +15,8 @@ struct Wrapper(u32);
struct TransparentWrapper(u32); struct TransparentWrapper(u32);
#[tokio::test] #[tokio::test]
async fn test_store_and_read() { async fn test_store_and_read() -> Result<()> {
run(&REGISTRATION, async { run(&REGISTRATION, || async {
let a: Vc<u32> = Vc::local_cell(42); let a: Vc<u32> = Vc::local_cell(42);
assert_eq!(*a.await.unwrap(), 42); assert_eq!(*a.await.unwrap(), 42);
...@@ -24,13 +25,15 @@ async fn test_store_and_read() { ...@@ -24,13 +25,15 @@ async fn test_store_and_read() {
let c = TransparentWrapper(42).local_cell(); let c = TransparentWrapper(42).local_cell();
assert_eq!(*c.await.unwrap(), 42); assert_eq!(*c.await.unwrap(), 42);
Ok(())
}) })
.await .await
} }
#[tokio::test] #[tokio::test]
async fn test_store_and_read_generic() { async fn test_store_and_read_generic() -> Result<()> {
run(&REGISTRATION, async { run(&REGISTRATION, || async {
// `Vc<Vec<Vc<T>>>` is stored as `Vc<Vec<Vc<()>>>` and requires special // `Vc<Vec<Vc<T>>>` is stored as `Vc<Vec<Vc<()>>>` and requires special
// transmute handling // transmute handling
let cells: Vc<Vec<Vc<u32>>> = let cells: Vc<Vec<Vc<u32>>> =
...@@ -42,6 +45,8 @@ async fn test_store_and_read_generic() { ...@@ -42,6 +45,8 @@ async fn test_store_and_read_generic() {
} }
assert_eq!(output, vec![1, 2, 3]); assert_eq!(output, vec![1, 2, 3]);
Ok(())
}) })
.await .await
} }
...@@ -53,10 +58,12 @@ async fn returns_resolved_local_vc() -> Vc<u32> { ...@@ -53,10 +58,12 @@ async fn returns_resolved_local_vc() -> Vc<u32> {
cell.resolve().await.unwrap() cell.resolve().await.unwrap()
} }
#[ignore]
#[tokio::test] #[tokio::test]
async fn test_return_resolved() { async fn test_return_resolved() -> Result<()> {
run(&REGISTRATION, async { run(&REGISTRATION, || async {
assert_eq!(*returns_resolved_local_vc().await.unwrap(), 42); assert_eq!(*returns_resolved_local_vc().await.unwrap(), 42);
Ok(())
}) })
.await .await
} }
...@@ -65,8 +72,8 @@ async fn test_return_resolved() { ...@@ -65,8 +72,8 @@ async fn test_return_resolved() {
trait UnimplementedTrait {} trait UnimplementedTrait {}
#[tokio::test] #[tokio::test]
async fn test_try_resolve_sidecast() { async fn test_try_resolve_sidecast() -> Result<()> {
run(&REGISTRATION, async { run(&REGISTRATION, || async {
let trait_vc: Vc<Box<dyn ValueDebug>> = Vc::upcast(Vc::<u32>::local_cell(42)); let trait_vc: Vc<Box<dyn ValueDebug>> = Vc::upcast(Vc::<u32>::local_cell(42));
// `u32` is both a `ValueDebug` and a `ValueDefault`, so this sidecast is valid // `u32` is both a `ValueDebug` and a `ValueDefault`, so this sidecast is valid
...@@ -80,13 +87,15 @@ async fn test_try_resolve_sidecast() { ...@@ -80,13 +87,15 @@ async fn test_try_resolve_sidecast() {
.await .await
.unwrap(); .unwrap();
assert!(wrongly_sidecast_vc.is_none()); assert!(wrongly_sidecast_vc.is_none());
Ok(())
}) })
.await .await
} }
#[tokio::test] #[tokio::test]
async fn test_try_resolve_downcast_type() { async fn test_try_resolve_downcast_type() -> Result<()> {
run(&REGISTRATION, async { run(&REGISTRATION, || async {
let trait_vc: Vc<Box<dyn ValueDebug>> = Vc::upcast(Vc::<u32>::local_cell(42)); let trait_vc: Vc<Box<dyn ValueDebug>> = Vc::upcast(Vc::<u32>::local_cell(42));
let downcast_vc: Vc<u32> = Vc::try_resolve_downcast_type(trait_vc) let downcast_vc: Vc<u32> = Vc::try_resolve_downcast_type(trait_vc)
...@@ -98,16 +107,19 @@ async fn test_try_resolve_downcast_type() { ...@@ -98,16 +107,19 @@ async fn test_try_resolve_downcast_type() {
let wrongly_downcast_vc: Option<Vc<i64>> = let wrongly_downcast_vc: Option<Vc<i64>> =
Vc::try_resolve_downcast_type(trait_vc).await.unwrap(); Vc::try_resolve_downcast_type(trait_vc).await.unwrap();
assert!(wrongly_downcast_vc.is_none()); assert!(wrongly_downcast_vc.is_none());
Ok(())
}) })
.await .await
} }
#[tokio::test] #[tokio::test]
async fn test_get_task_id() { async fn test_get_task_id() -> Result<()> {
run(&REGISTRATION, async { run(&REGISTRATION, || async {
// the task id as reported by the RawVc // the task id as reported by the RawVc
let vc_task_id = Vc::into_raw(Vc::<()>::local_cell(())).get_task_id(); let vc_task_id = Vc::into_raw(Vc::<()>::local_cell(())).get_task_id();
assert_eq!(vc_task_id, current_task_for_testing()); assert_eq!(vc_task_id, current_task_for_testing());
Ok(())
}) })
.await .await
} }
...@@ -139,25 +151,31 @@ async fn get_untracked_local_cell() -> Vc<Untracked> { ...@@ -139,25 +151,31 @@ async fn get_untracked_local_cell() -> Vc<Untracked> {
.unwrap() .unwrap()
} }
#[ignore]
#[tokio::test] #[tokio::test]
#[should_panic(expected = "Local Vcs must only be accessed within their own task")] #[should_panic(expected = "Local Vcs must only be accessed within their own task")]
async fn test_panics_on_local_cell_escape_read() { async fn test_panics_on_local_cell_escape_read() {
run(&REGISTRATION, async { run(&REGISTRATION, || async {
get_untracked_local_cell() get_untracked_local_cell()
.await .await
.unwrap() .unwrap()
.cell .cell
.await .await
.unwrap(); .unwrap();
Ok(())
}) })
.await .await
.unwrap()
} }
#[ignore]
#[tokio::test] #[tokio::test]
#[should_panic(expected = "Local Vcs must only be accessed within their own task")] #[should_panic(expected = "Local Vcs must only be accessed within their own task")]
async fn test_panics_on_local_cell_escape_get_task_id() { async fn test_panics_on_local_cell_escape_get_task_id() {
run(&REGISTRATION, async { run(&REGISTRATION, || async {
Vc::into_raw(get_untracked_local_cell().await.unwrap().cell).get_task_id(); Vc::into_raw(get_untracked_local_cell().await.unwrap().cell).get_task_id();
Ok(())
}) })
.await .await
.unwrap()
} }
...@@ -23,8 +23,8 @@ use crate::{ ...@@ -23,8 +23,8 @@ use crate::{
task::shared_reference::TypedSharedReference, task::shared_reference::TypedSharedReference,
trait_helpers::{get_trait_method, has_trait, traits}, trait_helpers::{get_trait_method, has_trait, traits},
triomphe_utils::unchecked_sidecast_triomphe_arc, triomphe_utils::unchecked_sidecast_triomphe_arc,
FunctionId, RawVc, ReadRef, SharedReference, TaskId, TaskIdSet, TraitRef, TraitTypeId, FunctionId, RawVc, ReadRef, SharedReference, TaskId, TaskIdSet, TaskPersistence, TraitRef,
ValueTypeId, VcRead, VcValueTrait, VcValueType, TraitTypeId, ValueTypeId, VcRead, VcValueTrait, VcValueType,
}; };
type TransientTaskRoot = type TransientTaskRoot =
...@@ -608,7 +608,7 @@ impl CachedTaskType { ...@@ -608,7 +608,7 @@ impl CachedTaskType {
fn_id: FunctionId, fn_id: FunctionId,
mut this: Option<RawVc>, mut this: Option<RawVc>,
arg: &dyn MagicAny, arg: &dyn MagicAny,
is_transient: bool, persistence: TaskPersistence,
turbo_tasks: Arc<dyn TurboTasksBackendApi<B>>, turbo_tasks: Arc<dyn TurboTasksBackendApi<B>>,
) -> Result<RawVc> { ) -> Result<RawVc> {
if let Some(this) = this.as_mut() { if let Some(this) = this.as_mut() {
...@@ -616,9 +616,9 @@ impl CachedTaskType { ...@@ -616,9 +616,9 @@ impl CachedTaskType {
} }
let arg = registry::get_function(fn_id).arg_meta.resolve(arg).await?; let arg = registry::get_function(fn_id).arg_meta.resolve(arg).await?;
Ok(if let Some(this) = this { Ok(if let Some(this) = this {
turbo_tasks.this_call(fn_id, this, arg, is_transient) turbo_tasks.this_call(fn_id, this, arg, persistence)
} else { } else {
turbo_tasks.native_call(fn_id, arg, is_transient) turbo_tasks.native_call(fn_id, arg, persistence)
}) })
} }
...@@ -636,7 +636,7 @@ impl CachedTaskType { ...@@ -636,7 +636,7 @@ impl CachedTaskType {
name: Cow<'static, str>, name: Cow<'static, str>,
this: RawVc, this: RawVc,
arg: &dyn MagicAny, arg: &dyn MagicAny,
is_transient: bool, persistence: TaskPersistence,
turbo_tasks: Arc<dyn TurboTasksBackendApi<B>>, turbo_tasks: Arc<dyn TurboTasksBackendApi<B>>,
) -> Result<RawVc> { ) -> Result<RawVc> {
let this = this.resolve().await?; let this = this.resolve().await?;
...@@ -647,7 +647,7 @@ impl CachedTaskType { ...@@ -647,7 +647,7 @@ impl CachedTaskType {
.arg_meta .arg_meta
.resolve(arg) .resolve(arg)
.await?; .await?;
Ok(turbo_tasks.dynamic_this_call(native_fn, this, arg, is_transient)) Ok(turbo_tasks.dynamic_this_call(native_fn, this, arg, persistence))
} }
/// Shared helper used by [`Self::resolve_trait_method`] and /// Shared helper used by [`Self::resolve_trait_method`] and
......
...@@ -7,7 +7,7 @@ use std::{ ...@@ -7,7 +7,7 @@ use std::{
use serde::{de::Visitor, Deserialize, Serialize}; use serde::{de::Visitor, Deserialize, Serialize};
use crate::registry; use crate::{registry, TaskPersistence};
macro_rules! define_id { macro_rules! define_id {
($name:ident : $primitive:ty $(,derive($($derive:ty),*))?) => { ($name:ident : $primitive:ty $(,derive($($derive:ty),*))?) => {
...@@ -84,6 +84,14 @@ impl TaskId { ...@@ -84,6 +84,14 @@ impl TaskId {
pub fn is_transient(&self) -> bool { pub fn is_transient(&self) -> bool {
**self & TRANSIENT_TASK_BIT != 0 **self & TRANSIENT_TASK_BIT != 0
} }
pub fn persistence(&self) -> TaskPersistence {
// tasks with `TaskPersistence::LocalCells` have no `TaskId`, so we can ignore that case
if self.is_transient() {
TaskPersistence::Transient
} else {
TaskPersistence::Persistent
}
}
} }
macro_rules! make_serializable { macro_rules! make_serializable {
......
...@@ -90,8 +90,8 @@ pub use magic_any::MagicAny; ...@@ -90,8 +90,8 @@ pub use magic_any::MagicAny;
pub use manager::{ pub use manager::{
dynamic_call, dynamic_this_call, emit, get_invalidator, mark_finished, mark_stateful, dynamic_call, dynamic_this_call, emit, get_invalidator, mark_finished, mark_stateful,
prevent_gc, run_once, run_once_with_reason, spawn_blocking, spawn_thread, trait_call, prevent_gc, run_once, run_once_with_reason, spawn_blocking, spawn_thread, trait_call,
turbo_tasks, CurrentCellRef, Invalidator, TurboTasks, TurboTasksApi, TurboTasksBackendApi, turbo_tasks, CurrentCellRef, Invalidator, TaskPersistence, TurboTasks, TurboTasksApi,
TurboTasksCallApi, Unused, UpdateInfo, TurboTasksBackendApi, TurboTasksCallApi, Unused, UpdateInfo,
}; };
pub use native_function::{FunctionMeta, NativeFunction}; pub use native_function::{FunctionMeta, NativeFunction};
pub use raw_vc::{CellId, RawVc, ReadRawVcFuture, ResolveTypeError}; pub use raw_vc::{CellId, RawVc, ReadRawVcFuture, ResolveTypeError};
......
...@@ -8,7 +8,7 @@ pub use super::{ ...@@ -8,7 +8,7 @@ pub use super::{
magic_any::MagicAny, magic_any::MagicAny,
manager::{find_cell_by_type, notify_scheduled_tasks, spawn_detached_for_testing}, manager::{find_cell_by_type, notify_scheduled_tasks, spawn_detached_for_testing},
}; };
use crate::debug::ValueDebugFormatString; use crate::{debug::ValueDebugFormatString, TaskInput, TaskPersistence};
#[inline(never)] #[inline(never)]
pub async fn value_debug_format_field(value: ValueDebugFormatString<'_>) -> String { pub async fn value_debug_format_field(value: ValueDebugFormatString<'_>) -> String {
...@@ -21,6 +21,14 @@ pub async fn value_debug_format_field(value: ValueDebugFormatString<'_>) -> Stri ...@@ -21,6 +21,14 @@ pub async fn value_debug_format_field(value: ValueDebugFormatString<'_>) -> Stri
} }
} }
pub fn get_non_local_persistence_from_inputs(inputs: &impl TaskInput) -> TaskPersistence {
if inputs.is_transient() {
TaskPersistence::Transient
} else {
TaskPersistence::Persistent
}
}
#[macro_export] #[macro_export]
macro_rules! stringify_path { macro_rules! stringify_path {
($path:path) => { ($path:path) => {
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment