Skip to content

Commit

Permalink
Demote InstalledScheduler::context() into dcou
Browse files Browse the repository at this point in the history
  • Loading branch information
ryoqun committed Dec 13, 2023
1 parent bfd618c commit 647b86f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ledger-tool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ solana-stake-program = { workspace = true }
solana-storage-bigtable = { workspace = true }
solana-streamer = { workspace = true }
solana-transaction-status = { workspace = true }
solana-unified-scheduler-pool = { workspace = true }
solana-unified-scheduler-pool = { workspace = true, features = ["dev-context-only-utils"] }
solana-version = { workspace = true }
solana-vote-program = { workspace = true }
solana_rbpf = { workspace = true, features = ["debugger"] }
Expand Down
2 changes: 2 additions & 0 deletions runtime/src/installed_scheduler_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ pub trait InstalledSchedulerPool: Send + Sync + Debug {
)]
pub trait InstalledScheduler: Send + Sync + Debug + 'static {
fn id(&self) -> SchedulerId;
#[cfg(feature = "dev-context-only-utils")]
fn context(&self) -> &SchedulingContext;

// Calling this is illegal as soon as wait_for_termination is called.
Expand Down Expand Up @@ -226,6 +227,7 @@ pub type InstalledSchedulerRwLock = RwLock<Option<DefaultInstalledSchedulerBox>>
impl BankWithScheduler {
#[cfg_attr(feature = "dev-context-only-utils", qualifiers(pub))]
pub(crate) fn new(bank: Arc<Bank>, scheduler: Option<DefaultInstalledSchedulerBox>) -> Self {
#[cfg(feature = "dev-context-only-utils")]
if let Some(bank_in_context) = scheduler
.as_ref()
.map(|scheduler| scheduler.context().bank())
Expand Down
7 changes: 7 additions & 0 deletions unified-scheduler-pool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,10 @@ solana-vote = { workspace = true }
assert_matches = { workspace = true }
solana-logger = { workspace = true }
solana-runtime = { workspace = true, features = ["dev-context-only-utils"] }
# See order-crates-for-publishing.py for using this unusual `path = "."`
solana-unified-scheduler-pool = { path = ".", features = ["dev-context-only-utils"] }

[features]
dev-context-only-utils = [
"solana-runtime/dev-context-only-utils",
]
4 changes: 3 additions & 1 deletion unified-scheduler-pool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ impl<TH: TaskHandler> InstalledScheduler for PooledScheduler<TH> {
self.id
}

#[cfg(feature = "dev-context-only-utils")]
fn context(&self) -> &SchedulingContext {
self.context.as_ref().expect("active context should exist")
}
Expand All @@ -256,7 +257,7 @@ impl<TH: TaskHandler> InstalledScheduler for PooledScheduler<TH> {
TH::handle(
result,
timings,
self.context().bank(),
self.context.as_ref().unwrap().bank(),
transaction,
index,
&self.pool.handler_context,
Expand Down Expand Up @@ -563,6 +564,7 @@ mod tests {
self.0.id()
}

#[cfg(feature = "dev-context-only-utils")]
fn context(&self) -> &SchedulingContext {
self.0.context()
}
Expand Down

0 comments on commit 647b86f

Please sign in to comment.