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
fe742f15
Commit
fe742f15
authored
Mar 06, 2026
by
Benjamin Woodruff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reorder generation bump and lock, rename QueueState to QueuePair
parent
749c94eb
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
tx_cache.rs
.../crates/turbo-tasks-backend/src/database/lmdb/tx_cache.rs
+7
-7
No files found.
turbopack/crates/turbo-tasks-backend/src/database/lmdb/tx_cache.rs
View file @
fe742f15
...
@@ -33,12 +33,12 @@ impl<'tx> Deref for SendRoTransaction<'tx> {
...
@@ -33,12 +33,12 @@ impl<'tx> Deref for SendRoTransaction<'tx> {
// allows moving ownership between threads when queue internals move transactions across threads.
// allows moving ownership between threads when queue internals move transactions across threads.
unsafe
impl
<
'tx
>
Send
for
SendRoTransaction
<
'tx
>
{}
unsafe
impl
<
'tx
>
Send
for
SendRoTransaction
<
'tx
>
{}
struct
Queue
State
{
struct
Queue
Pair
{
sender
:
SyncSender
<
SendRoTransaction
<
'static
>>
,
sender
:
SyncSender
<
SendRoTransaction
<
'static
>>
,
receiver
:
Arc
<
Mutex
<
Receiver
<
SendRoTransaction
<
'static
>>>>
,
receiver
:
Arc
<
Mutex
<
Receiver
<
SendRoTransaction
<
'static
>>>>
,
}
}
impl
Queue
State
{
impl
Queue
Pair
{
fn
new
(
env
:
&
Environment
,
capacity
:
usize
,
generation
:
u64
)
->
Self
{
fn
new
(
env
:
&
Environment
,
capacity
:
usize
,
generation
:
u64
)
->
Self
{
let
(
sender
,
receiver
)
=
sync_channel
(
capacity
);
let
(
sender
,
receiver
)
=
sync_channel
(
capacity
);
for
_
in
0
..
capacity
{
for
_
in
0
..
capacity
{
...
@@ -126,7 +126,7 @@ impl RwTransactionGuard<'_> {
...
@@ -126,7 +126,7 @@ impl RwTransactionGuard<'_> {
}
}
struct
RebuildQueueOnDrop
<
'db
>
{
struct
RebuildQueueOnDrop
<
'db
>
{
queue
:
RwLockWriteGuard
<
'db
,
Queue
State
>
,
queue
:
RwLockWriteGuard
<
'db
,
Queue
Pair
>
,
env
:
&
'db
Environment
,
env
:
&
'db
Environment
,
generation
:
u64
,
generation
:
u64
,
capacity
:
usize
,
capacity
:
usize
,
...
@@ -137,13 +137,13 @@ impl Drop for RebuildQueueOnDrop<'_> {
...
@@ -137,13 +137,13 @@ impl Drop for RebuildQueueOnDrop<'_> {
// We might avoid some allocation overhead if we used RoTransaction::reset and
// We might avoid some allocation overhead if we used RoTransaction::reset and
// InactiveTransaction::renew, but we don't care much about perf here.
// InactiveTransaction::renew, but we don't care much about perf here.
// https://docs.rs/lmdb/latest/lmdb/struct.RoTransaction.html#method.reset
// https://docs.rs/lmdb/latest/lmdb/struct.RoTransaction.html#method.reset
*
self
.queue
=
Queue
State
::
new
(
self
.env
,
self
.capacity
,
self
.generation
);
*
self
.queue
=
Queue
Pair
::
new
(
self
.env
,
self
.capacity
,
self
.generation
);
}
}
}
}
pub
struct
TxCache
{
pub
struct
TxCache
{
generation
:
AtomicU64
,
generation
:
AtomicU64
,
queue
:
RwLock
<
Queue
State
>
,
queue
:
RwLock
<
Queue
Pair
>
,
capacity
:
usize
,
capacity
:
usize
,
}
}
...
@@ -151,14 +151,14 @@ impl TxCache {
...
@@ -151,14 +151,14 @@ impl TxCache {
pub
fn
new
(
env
:
&
Environment
,
capacity
:
usize
)
->
Self
{
pub
fn
new
(
env
:
&
Environment
,
capacity
:
usize
)
->
Self
{
Self
{
Self
{
generation
:
AtomicU64
::
new
(
0
),
generation
:
AtomicU64
::
new
(
0
),
queue
:
RwLock
::
new
(
Queue
State
::
new
(
env
,
capacity
,
0
)),
queue
:
RwLock
::
new
(
Queue
Pair
::
new
(
env
,
capacity
,
0
)),
capacity
,
capacity
,
}
}
}
}
pub
fn
get_write_tx
<
'db
>
(
&
'db
self
,
env
:
&
'db
Environment
)
->
Result
<
RwTransactionGuard
<
'db
>>
{
pub
fn
get_write_tx
<
'db
>
(
&
'db
self
,
env
:
&
'db
Environment
)
->
Result
<
RwTransactionGuard
<
'db
>>
{
let
generation
=
self
.generation
.fetch_add
(
1
,
Ordering
::
AcqRel
)
+
1
;
let
queue
=
self
.queue
.write
()
.unwrap_or_else
(
PoisonError
::
into_inner
);
let
queue
=
self
.queue
.write
()
.unwrap_or_else
(
PoisonError
::
into_inner
);
let
generation
=
self
.generation
.fetch_add
(
1
,
Ordering
::
AcqRel
)
+
1
;
let
tx
=
env
.begin_rw_txn
()
?
;
let
tx
=
env
.begin_rw_txn
()
?
;
Ok
(
RwTransactionGuard
{
Ok
(
RwTransactionGuard
{
tx
,
tx
,
...
...
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