1
1
pub ( crate ) use maybe_changed_after:: VerifyResult ;
2
2
use std:: any:: Any ;
3
- use std:: fmt ;
3
+ use std:: marker :: PhantomData ;
4
4
use std:: ptr:: NonNull ;
5
5
use std:: sync:: atomic:: Ordering ;
6
6
use std:: sync:: OnceLock ;
7
+ use std:: { fmt, mem} ;
7
8
pub ( crate ) use sync:: SyncGuard ;
8
9
9
10
use crate :: cycle:: {
10
11
empty_cycle_heads, CycleHeadKeys , CycleHeads , CycleRecoveryAction , CycleRecoveryStrategy ,
11
12
ProvisionalStatus ,
12
13
} ;
13
14
use crate :: database:: RawDatabase ;
14
- use crate :: function:: delete:: DeletedEntries ;
15
15
use crate :: function:: sync:: { ClaimResult , SyncTable } ;
16
16
use crate :: ingredient:: { Ingredient , WaitForResult } ;
17
17
use crate :: key:: DatabaseKeyIndex ;
18
18
use crate :: plumbing:: MemoIngredientMap ;
19
19
use crate :: salsa_struct:: SalsaStructInDb ;
20
20
use crate :: sync:: Arc ;
21
- use crate :: table:: memo:: MemoTableTypes ;
21
+ use crate :: table:: memo:: { DeletedEntries , MemoTableTypes } ;
22
22
use crate :: table:: Table ;
23
23
use crate :: views:: DatabaseDownCaster ;
24
24
use crate :: zalsa:: { IngredientIndex , MemoIngredientIndex , Zalsa } ;
@@ -28,7 +28,6 @@ use crate::{Id, Revision};
28
28
#[ cfg( feature = "accumulator" ) ]
29
29
mod accumulated;
30
30
mod backdate;
31
- mod delete;
32
31
mod diff_outputs;
33
32
mod execute;
34
33
mod fetch;
@@ -147,7 +146,8 @@ pub struct IngredientImpl<C: Configuration> {
147
146
/// current revision: you would be right, but we are being defensive, because
148
147
/// we don't know that we can trust the database to give us the same runtime
149
148
/// everytime and so forth.
150
- deleted_entries : DeletedEntries < C > ,
149
+ delete : DeletedEntries ,
150
+ config : PhantomData < fn ( C ) -> C > ,
151
151
}
152
152
153
153
impl < C > IngredientImpl < C >
@@ -162,10 +162,11 @@ where
162
162
Self {
163
163
index,
164
164
memo_ingredient_indices,
165
- lru : lru:: Lru :: new ( lru) ,
166
- deleted_entries : Default :: default ( ) ,
167
165
view_caster : OnceLock :: new ( ) ,
166
+ lru : lru:: Lru :: new ( lru) ,
167
+ delete : DeletedEntries :: default ( ) ,
168
168
sync_table : SyncTable :: new ( index) ,
169
+ config : PhantomData ,
169
170
}
170
171
}
171
172
@@ -222,16 +223,7 @@ where
222
223
// FIXME: Use `Box::into_non_null` once stable
223
224
let memo = NonNull :: from ( Box :: leak ( Box :: new ( memo) ) ) ;
224
225
225
- if let Some ( old_value) =
226
- self . insert_memo_into_table_for ( zalsa, id, memo, memo_ingredient_index)
227
- {
228
- // In case there is a reference to the old memo out there, we have to store it
229
- // in the deleted entries. This will get cleared when a new revision starts.
230
- //
231
- // SAFETY: Once the revision starts, there will be no outstanding borrows to the
232
- // memo contents, and so it will be safe to free.
233
- unsafe { self . deleted_entries . push ( old_value) } ;
234
- }
226
+ self . insert_memo_into_table_for ( zalsa, id, memo, memo_ingredient_index) ;
235
227
// SAFETY: memo has been inserted into the table
236
228
unsafe { self . extend_memo_lifetime ( memo. as_ref ( ) ) }
237
229
}
@@ -344,16 +336,19 @@ where
344
336
true
345
337
}
346
338
347
- fn reset_for_new_revision ( & mut self , table : & mut Table ) {
339
+ fn reset_for_new_revision (
340
+ & mut self ,
341
+ table : & mut Table ,
342
+ new_buffer : DeletedEntries ,
343
+ ) -> DeletedEntries {
348
344
self . lru . for_each_evicted ( |evict| {
349
345
let ingredient_index = table. ingredient_index ( evict) ;
350
346
Self :: evict_value_from_memo_for (
351
347
table. memos_mut ( evict) ,
352
348
self . memo_ingredient_indices . get ( ingredient_index) ,
353
349
)
354
350
} ) ;
355
-
356
- self . deleted_entries . clear ( ) ;
351
+ mem:: replace ( & mut self . delete , new_buffer)
357
352
}
358
353
359
354
fn debug_name ( & self ) -> & ' static str {
0 commit comments