Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit 88dcdc2

Browse files
committed
Clean up wait_for_* fns
1 parent cf676d3 commit 88dcdc2

File tree

3 files changed

+23
-22
lines changed

3 files changed

+23
-22
lines changed

runtime/src/bank.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4193,7 +4193,7 @@ impl Bank {
41934193
) {
41944194
// This is needed because recent_blockhash updates necessitate synchronizations for
41954195
// consistent tx check_age handling.
4196-
BankWithScheduler::wait_for_reusable_scheduler(self, scheduler);
4196+
BankWithScheduler::wait_for_paused_scheduler(self, scheduler);
41974197

41984198
// Only acquire the write lock for the blockhash queue on block boundaries because
41994199
// readers can starve this write lock acquisition and ticks would be slowed down too

runtime/src/installed_scheduler_pool.rs

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,23 @@ impl BankWithScheduler {
299299

300300
#[must_use]
301301
pub fn wait_for_completed_scheduler(&self) -> Option<ResultWithTimings> {
302-
self.inner
303-
.wait_for_scheduler(WaitReason::TerminatedToFreeze)
302+
BankWithSchedulerInner::wait_for_scheduler(
303+
&self.inner.bank,
304+
&self.inner.scheduler,
305+
WaitReason::TerminatedToFreeze,
306+
)
304307
}
305308

306-
pub(crate) fn wait_for_reusable_scheduler(bank: &Bank, scheduler: &InstalledSchedulerRwLock) {
307-
BankWithSchedulerInner::wait_for_reusable_scheduler(bank, scheduler);
309+
pub(crate) fn wait_for_paused_scheduler(bank: &Bank, scheduler: &InstalledSchedulerRwLock) {
310+
let maybe_result_with_timings = BankWithSchedulerInner::wait_for_scheduler(
311+
bank,
312+
scheduler,
313+
WaitReason::PausedForRecentBlockhash,
314+
);
315+
assert!(
316+
maybe_result_with_timings.is_none(),
317+
"Premature result was returned from scheduler after paused"
318+
);
308319
}
309320

310321
// take needless &mut only to communicate its semantic mutability to humans...
@@ -338,12 +349,7 @@ impl BankWithScheduler {
338349

339350
impl BankWithSchedulerInner {
340351
#[must_use]
341-
fn wait_for_scheduler(&self, reason: WaitReason) -> Option<ResultWithTimings> {
342-
Self::do_wait_for_scheduler(&self.bank, &self.scheduler, reason)
343-
}
344-
345-
#[must_use]
346-
fn do_wait_for_scheduler(
352+
fn wait_for_scheduler(
347353
bank: &Bank,
348354
scheduler: &InstalledSchedulerRwLock,
349355
reason: WaitReason,
@@ -379,17 +385,12 @@ impl BankWithSchedulerInner {
379385

380386
#[must_use]
381387
fn wait_for_completed_scheduler_from_drop(&self) -> Option<Result<()>> {
382-
let maybe_result_with_timings = self.wait_for_scheduler(WaitReason::DroppedFromBankForks);
383-
maybe_result_with_timings.map(|(result, _timings)| result)
384-
}
385-
386-
fn wait_for_reusable_scheduler(bank: &Bank, scheduler: &InstalledSchedulerRwLock) {
387-
let maybe_result_with_timings =
388-
Self::do_wait_for_scheduler(bank, scheduler, WaitReason::PausedForRecentBlockhash);
389-
assert!(
390-
maybe_result_with_timings.is_none(),
391-
"Premature result was returned from scheduler after paused"
388+
let maybe_result_with_timings = Self::wait_for_scheduler(
389+
&self.bank,
390+
&self.scheduler,
391+
WaitReason::DroppedFromBankForks,
392392
);
393+
maybe_result_with_timings.map(|(result, _timings)| result)
393394
}
394395

395396
fn drop_scheduler(&self) {

scheduler-pool/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ mod tests {
638638

639639
fn wait_for_termination(&mut self, reason: &WaitReason) -> Option<ResultWithTimings> {
640640
if TRIGGER_RACE_CONDITION && matches!(reason, WaitReason::PausedForRecentBlockhash) {
641-
// this is equivalent to NOT calling wait_for_reusable_scheduler() in
641+
// this is equivalent to NOT calling wait_for_paused_scheduler() in
642642
// register_recent_blockhash().
643643
return None;
644644
}

0 commit comments

Comments
 (0)