Fix regression from prior changes that broke determinism again, simplify the code to avoid that happening again.
This commit is contained in:
1 parent
1ff5037fe2
commit
da152f5bd8
1 file changed
+5
-6
+5
-6
@@ -98,7 +98,6 @@ class _FdProducer:
|
||||
timer = stopwatch()
|
||||
|
||||
try:
|
||||
slot = -1 # No slot to commit on first iteration
|
||||
while True:
|
||||
# Claim next block number
|
||||
with self.lock_blkno:
|
||||
@@ -108,11 +107,6 @@ class _FdProducer:
|
||||
|
||||
with self._lock:
|
||||
stats.lock_acquire_time += next(timer)
|
||||
# Commit previous block (mark ready + notify consumer)
|
||||
if slot >= 0:
|
||||
self.ready[slot] = True
|
||||
self.has_data.notify()
|
||||
stats.lock_notify_time += next(timer)
|
||||
# Wait for the NEXT slot to be free
|
||||
slot = blkno % self.num_slots
|
||||
while self.ready[slot] and not self.quit:
|
||||
@@ -132,6 +126,11 @@ class _FdProducer:
|
||||
stats.blocks_processed += 1
|
||||
stats.bytes_generated += self.block_size
|
||||
|
||||
# Commit block (mark ready + notify consumer)
|
||||
with self._lock:
|
||||
self.ready[slot] = True
|
||||
self.has_data.notify()
|
||||
|
||||
finally:
|
||||
view.release()
|
||||
with self._stats_lock:
|
||||
|
||||
Reference in new issue
Block a user