@@ -4,7 +4,7 @@ use crate::function::{Configuration, IngredientImpl};
4
4
use crate :: sync:: atomic:: { AtomicBool , Ordering } ;
5
5
use crate :: zalsa:: { MemoIngredientIndex , Zalsa , ZalsaDatabase } ;
6
6
use crate :: zalsa_local:: { ActiveQueryGuard , QueryRevisions } ;
7
- use crate :: { Event , EventKind , Id , Revision } ;
7
+ use crate :: { Event , EventKind , Id } ;
8
8
9
9
impl < C > IngredientImpl < C >
10
10
where
@@ -41,16 +41,11 @@ where
41
41
42
42
let ( new_value, mut revisions) = match C :: CYCLE_STRATEGY {
43
43
CycleRecoveryStrategy :: Panic => {
44
- Self :: execute_query ( db, active_query , opt_old_memo , zalsa . current_revision ( ) , id)
44
+ Self :: execute_query ( db, zalsa , active_query , opt_old_memo , id)
45
45
}
46
46
CycleRecoveryStrategy :: FallbackImmediate => {
47
- let ( mut new_value, mut revisions) = Self :: execute_query (
48
- db,
49
- active_query,
50
- opt_old_memo,
51
- zalsa. current_revision ( ) ,
52
- id,
53
- ) ;
47
+ let ( mut new_value, mut revisions) =
48
+ Self :: execute_query ( db, zalsa, active_query, opt_old_memo, id) ;
54
49
55
50
if let Some ( cycle_heads) = revisions. cycle_heads_mut ( ) {
56
51
// Did the new result we got depend on our own provisional value, in a cycle?
77
72
let active_query = db
78
73
. zalsa_local ( )
79
74
. push_query ( database_key_index, IterationCount :: initial ( ) ) ;
80
- new_value = C :: cycle_initial ( db, C :: id_to_input ( db , id) ) ;
75
+ new_value = C :: cycle_initial ( db, C :: id_to_input ( zalsa , id) ) ;
81
76
revisions = active_query. pop ( ) ;
82
77
// We need to set `cycle_heads` and `verified_final` because it needs to propagate to the callers.
83
78
// When verifying this, we will see we have fallback and mark ourselves verified.
@@ -136,13 +131,8 @@ where
136
131
let mut opt_last_provisional: Option < & Memo < ' db , C > > = None ;
137
132
loop {
138
133
let previous_memo = opt_last_provisional. or ( opt_old_memo) ;
139
- let ( mut new_value, mut revisions) = Self :: execute_query (
140
- db,
141
- active_query,
142
- previous_memo,
143
- zalsa. current_revision ( ) ,
144
- id,
145
- ) ;
134
+ let ( mut new_value, mut revisions) =
135
+ Self :: execute_query ( db, zalsa, active_query, previous_memo, id) ;
146
136
147
137
// Did the new result we got depend on our own provisional value, in a cycle?
148
138
if let Some ( cycle_heads) = revisions
@@ -192,7 +182,7 @@ where
192
182
db,
193
183
& new_value,
194
184
iteration_count. as_u32 ( ) ,
195
- C :: id_to_input ( db , id) ,
185
+ C :: id_to_input ( zalsa , id) ,
196
186
) {
197
187
crate :: CycleRecoveryAction :: Iterate => { }
198
188
crate :: CycleRecoveryAction :: Fallback ( fallback_value) => {
@@ -258,9 +248,9 @@ where
258
248
#[ inline]
259
249
fn execute_query < ' db > (
260
250
db : & ' db C :: DbView ,
251
+ zalsa : & ' db Zalsa ,
261
252
active_query : ActiveQueryGuard < ' db > ,
262
253
opt_old_memo : Option < & Memo < ' db , C > > ,
263
- current_revision : Revision ,
264
254
id : Id ,
265
255
) -> ( C :: Output < ' db > , QueryRevisions ) {
266
256
if let Some ( old_memo) = opt_old_memo {
@@ -275,14 +265,16 @@ where
275
265
// * ensure that tracked struct created during the previous iteration
276
266
// (and are owned by the query) are alive even if the query in this iteration no longer creates them.
277
267
// * ensure the final returned memo depends on all inputs from all iterations.
278
- if old_memo. may_be_provisional ( ) && old_memo. verified_at . load ( ) == current_revision {
268
+ if old_memo. may_be_provisional ( )
269
+ && old_memo. verified_at . load ( ) == zalsa. current_revision ( )
270
+ {
279
271
active_query. seed_iteration ( & old_memo. revisions ) ;
280
272
}
281
273
}
282
274
283
275
// Query was not previously executed, or value is potentially
284
276
// stale, or value is absent. Let's execute!
285
- let new_value = C :: execute ( db, C :: id_to_input ( db , id) ) ;
277
+ let new_value = C :: execute ( db, C :: id_to_input ( zalsa , id) ) ;
286
278
287
279
( new_value, active_query. pop ( ) )
288
280
}
0 commit comments