Skip to content

Commit

Permalink
rename set_priority to upgrade_priority (TraceMachina#1112)
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-singer authored Jul 8, 2024
1 parent 0d93671 commit d353c30
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions nativelink-scheduler/src/scheduler_state/awaited_action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,17 @@ impl AwaitedAction {
.store(SystemTime::now().unix_timestamp(), Ordering::Release);
}

/// Sets the priority of the action.
/// Upgrades the priority of the action if new priority is higher.
///
/// If the priority was already set to `new_priority`, this function will
/// return `None`. If the priority was different, it will return a
/// struct that contains the previous sort key and the new sort key and
/// will hold a lock preventing anyone else from reading or modifying the
/// sort key until the result is dropped.
#[must_use]
pub fn set_priority(&self, new_priority: i32) -> Option<SortInfoLock> {
pub fn upgrade_priority(&self, new_priority: i32) -> Option<SortInfoLock> {
let sort_info_lock = self.sort_info.upgradable_read();
if sort_info_lock.priority == new_priority {
if sort_info_lock.priority >= new_priority {
return None;
}
let mut sort_info_lock = RwLockUpgradableReadGuard::upgrade(sort_info_lock);
Expand Down
2 changes: 1 addition & 1 deletion nativelink-scheduler/src/scheduler_state/state_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ impl AwaitedActionDb {
));
}
let awaited_action = awaited_action.clone();
if let Some(sort_info_lock) = awaited_action.set_priority(priority) {
if let Some(sort_info_lock) = awaited_action.upgrade_priority(priority) {
let state = awaited_action.get_current_state();
let maybe_sorted_awaited_action =
self.get_sort_map_for_state(&state.stage)
Expand Down

0 comments on commit d353c30

Please sign in to comment.