Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tags to turbo tasks #8038

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/turbo-tasks-fetch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub enum ProxyConfig {
#[turbo_tasks::value(transparent)]
pub struct OptionProxyConfig(Option<ProxyConfig>);

#[turbo_tasks::function]
#[turbo_tasks::function(network)]
pub async fn fetch(
url: Vc<RcStr>,
user_agent: Vc<Option<RcStr>>,
Expand Down
12 changes: 6 additions & 6 deletions crates/turbo-tasks-fs/src/attach.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,17 @@ impl AttachedFileSystem {

#[turbo_tasks::value_impl]
impl FileSystem for AttachedFileSystem {
#[turbo_tasks::function]
#[turbo_tasks::function(fs)]
fn read(self: Vc<Self>, path: Vc<FileSystemPath>) -> Vc<FileContent> {
self.get_inner_fs_path(path).read()
}

#[turbo_tasks::function]
#[turbo_tasks::function(fs)]
fn read_link(self: Vc<Self>, path: Vc<FileSystemPath>) -> Vc<LinkContent> {
self.get_inner_fs_path(path).read_link()
}

#[turbo_tasks::function]
#[turbo_tasks::function(fs)]
async fn read_dir(self: Vc<Self>, path: Vc<FileSystemPath>) -> Result<Vc<DirectoryContent>> {
let dir_content = self.get_inner_fs_path(path).read_dir().await?;
let entries = match &*dir_content {
Expand All @@ -157,17 +157,17 @@ impl FileSystem for AttachedFileSystem {
Ok(DirectoryContent::new(converted_entries))
}

#[turbo_tasks::function]
#[turbo_tasks::function(fs)]
fn track(self: Vc<Self>, path: Vc<FileSystemPath>) -> Vc<Completion> {
self.get_inner_fs_path(path).track()
}

#[turbo_tasks::function]
#[turbo_tasks::function(fs)]
fn write(self: Vc<Self>, path: Vc<FileSystemPath>, content: Vc<FileContent>) -> Vc<Completion> {
self.get_inner_fs_path(path).write(content)
}

#[turbo_tasks::function]
#[turbo_tasks::function(fs)]
fn write_link(
self: Vc<Self>,
path: Vc<FileSystemPath>,
Expand Down
14 changes: 7 additions & 7 deletions crates/turbo-tasks-fs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ impl Debug for DiskFileSystem {

#[turbo_tasks::value_impl]
impl FileSystem for DiskFileSystem {
#[turbo_tasks::function]
#[turbo_tasks::function(fs)]
async fn read(&self, fs_path: Vc<FileSystemPath>) -> Result<Vc<FileContent>> {
let full_path = self.to_sys_path(fs_path).await?;
self.register_invalidator(&full_path)?;
Expand All @@ -341,7 +341,7 @@ impl FileSystem for DiskFileSystem {
Ok(content.cell())
}

#[turbo_tasks::function]
#[turbo_tasks::function(fs)]
async fn read_dir(&self, fs_path: Vc<FileSystemPath>) -> Result<Vc<DirectoryContent>> {
let full_path = self.to_sys_path(fs_path).await?;
self.register_dir_invalidator(&full_path)?;
Expand Down Expand Up @@ -400,7 +400,7 @@ impl FileSystem for DiskFileSystem {
Ok(DirectoryContent::new(entries))
}

#[turbo_tasks::function]
#[turbo_tasks::function(fs)]
async fn read_link(&self, fs_path: Vc<FileSystemPath>) -> Result<Vc<LinkContent>> {
let full_path = self.to_sys_path(fs_path).await?;
self.register_invalidator(&full_path)?;
Expand Down Expand Up @@ -484,14 +484,14 @@ impl FileSystem for DiskFileSystem {
.cell())
}

#[turbo_tasks::function]
#[turbo_tasks::function(fs)]
async fn track(&self, fs_path: Vc<FileSystemPath>) -> Result<Vc<Completion>> {
let full_path = self.to_sys_path(fs_path).await?;
self.register_invalidator(&full_path)?;
Ok(Completion::new())
}

#[turbo_tasks::function]
#[turbo_tasks::function(fs)]
async fn write(
&self,
fs_path: Vc<FileSystemPath>,
Expand Down Expand Up @@ -605,7 +605,7 @@ impl FileSystem for DiskFileSystem {
Ok(Completion::new())
}

#[turbo_tasks::function]
#[turbo_tasks::function(fs)]
async fn write_link(
&self,
fs_path: Vc<FileSystemPath>,
Expand Down Expand Up @@ -692,7 +692,7 @@ impl FileSystem for DiskFileSystem {
Ok(Completion::new())
}

#[turbo_tasks::function]
#[turbo_tasks::function(fs)]
async fn metadata(&self, fs_path: Vc<FileSystemPath>) -> Result<Vc<FileMeta>> {
let full_path = self.to_sys_path(fs_path).await?;
self.register_invalidator(&full_path)?;
Expand Down
4 changes: 2 additions & 2 deletions crates/turbo-tasks-fs/src/read_glob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct ReadGlobResult {
///
/// DETERMINISM: Result is in random order. Either sort result or do not depend
/// on the order.
#[turbo_tasks::function]
#[turbo_tasks::function(fs)]
pub async fn read_glob(
directory: Vc<FileSystemPath>,
glob: Vc<Glob>,
Expand All @@ -25,7 +25,7 @@ pub async fn read_glob(
read_glob_internal("", directory, glob, include_dot_files).await
}

#[turbo_tasks::function]
#[turbo_tasks::function(fs)]
async fn read_glob_inner(
prefix: RcStr,
directory: Vc<FileSystemPath>,
Expand Down
19 changes: 19 additions & 0 deletions crates/turbo-tasks-macros/src/function_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,25 @@ use turbo_tasks_macros_shared::{get_native_function_id_ident, get_native_functio

use crate::func::{DefinitionContext, NativeFn, TurboFn};

/// This macro generates the virtual function that powers turbo tasks.
/// An annotated task is replaced with a stub function that returns a
/// lazy completion (Vc), and stamps out the concrete implementation
/// of the task alongside that the Vc uses to resolve itself.
///
/// Functions support being tagged for informational purposes. This
/// is currently only used in turbo-static for doing static analysis
/// of tasks.
///
/// # Examples
///
/// ```rust
/// use turbo_tasks::{Vc};
///
/// #[turbo_tasks::function(fs)]
/// async fn my_task() -> Vc<usize> {
/// // access filesystem
/// }
/// ```
pub fn function(_args: TokenStream, input: TokenStream) -> TokenStream {
let item = parse_macro_input!(input as ItemFn);

Expand Down
Loading