Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
de34a06b
Commit
de34a06b
authored
Oct 02, 2025
by
Tobias Koppers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix scope holding arc to long
parent
e5e39c60
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
scope.rs
turbopack/crates/turbo-tasks/src/scope.rs
+11
-11
No files found.
turbopack/crates/turbo-tasks/src/scope.rs
View file @
de34a06b
...
@@ -195,8 +195,17 @@ impl<'scope, 'env: 'scope, R: Send + 'env> Scope<'scope, 'env, R> {
...
@@ -195,8 +195,17 @@ impl<'scope, 'env: 'scope, R: Send + 'env> Scope<'scope, 'env, R> {
assert
!
(
index
<
self
.results
.len
(),
"Too many tasks spawned"
);
assert
!
(
index
<
self
.results
.len
(),
"Too many tasks spawned"
);
let
result_cell
:
&
Mutex
<
Option
<
R
>>
=
&
self
.results
[
index
];
let
result_cell
:
&
Mutex
<
Option
<
R
>>
=
&
self
.results
[
index
];
let
turbo_tasks
=
self
.turbo_tasks
.clone
();
let
f
:
Box
<
dyn
FnOnce
()
+
Send
+
'scope
>
=
Box
::
new
(||
{
let
f
:
Box
<
dyn
FnOnce
()
+
Send
+
'scope
>
=
Box
::
new
(||
{
let
result
=
f
();
let
result
=
{
if
let
Some
(
turbo_tasks
)
=
turbo_tasks
{
// Ensure that the turbo tasks context is maintained across the job.
turbo_tasks_scope
(
turbo_tasks
,
f
)
}
else
{
// If no turbo tasks context is available, just run the job.
f
()
}
};
*
result_cell
.lock
()
=
Some
(
result
);
*
result_cell
.lock
()
=
Some
(
result
);
});
});
let
f
:
*
mut
(
dyn
FnOnce
()
+
Send
+
'scope
)
=
Box
::
into_raw
(
f
);
let
f
:
*
mut
(
dyn
FnOnce
()
+
Send
+
'scope
)
=
Box
::
into_raw
(
f
);
...
@@ -210,7 +219,6 @@ impl<'scope, 'env: 'scope, R: Send + 'env> Scope<'scope, 'env, R> {
...
@@ -210,7 +219,6 @@ impl<'scope, 'env: 'scope, R: Send + 'env> Scope<'scope, 'env, R> {
// SAFETY: We just called `Box::into_raw`.
// SAFETY: We just called `Box::into_raw`.
let
f
=
unsafe
{
Box
::
from_raw
(
f
)
};
let
f
=
unsafe
{
Box
::
from_raw
(
f
)
};
let
turbo_tasks
=
self
.turbo_tasks
.clone
();
let
span
=
self
.span
.clone
();
let
span
=
self
.span
.clone
();
self
.inner.remaining_tasks
.fetch_add
(
1
,
Ordering
::
Relaxed
);
self
.inner.remaining_tasks
.fetch_add
(
1
,
Ordering
::
Relaxed
);
...
@@ -223,15 +231,7 @@ impl<'scope, 'env: 'scope, R: Send + 'env> Scope<'scope, 'env, R> {
...
@@ -223,15 +231,7 @@ impl<'scope, 'env: 'scope, R: Send + 'env> Scope<'scope, 'env, R> {
// Spawn a worker task that will process that tasks and potentially more.
// Spawn a worker task that will process that tasks and potentially more.
self
.handle
.spawn
(
async
move
{
self
.handle
.spawn
(
async
move
{
let
_span
=
span
.entered
();
let
_span
=
span
.entered
();
if
let
Some
(
turbo_tasks
)
=
turbo_tasks
{
inner
.worker
(
index
,
f
);
// Ensure that the turbo tasks context is maintained across the worker.
turbo_tasks_scope
(
turbo_tasks
,
||
{
inner
.worker
(
index
,
f
);
});
}
else
{
// If no turbo tasks context is available, just run the worker.
inner
.worker
(
index
,
f
);
}
});
});
}
else
{
}
else
{
// Queue the task to be processed by a worker task.
// Queue the task to be processed by a worker task.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment