Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

console: show spawn location as a column #166

Merged
merged 4 commits into from Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions console/src/state/tasks.rs
Expand Up @@ -41,6 +41,8 @@ pub(crate) enum SortBy {
Busy = 5,
Idle = 6,
Polls = 7,
Target = 8,
Location = 9,
}

#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
Expand Down Expand Up @@ -416,6 +418,11 @@ impl SortBy {
Self::Polls => {
tasks.sort_unstable_by_key(|task| task.upgrade().map(|t| t.borrow().stats.polls))
}
Self::Target => {
tasks.sort_unstable_by_key(|task| task.upgrade().map(|t| t.borrow().target.clone()))
}
Comment on lines +421 to +423
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for adding this as well!

Self::Location => tasks
.sort_unstable_by_key(|task| task.upgrade().map(|t| t.borrow().location.clone())),
}
}
}
Expand All @@ -438,6 +445,8 @@ impl TryFrom<usize> for SortBy {
idx if idx == Self::Busy as usize => Ok(Self::Busy),
idx if idx == Self::Idle as usize => Ok(Self::Idle),
idx if idx == Self::Polls as usize => Ok(Self::Polls),
idx if idx == Self::Target as usize => Ok(Self::Target),
idx if idx == Self::Location as usize => Ok(Self::Location),
_ => Err(()),
}
}
Expand Down
2 changes: 1 addition & 1 deletion console/src/view/task.rs
Expand Up @@ -148,7 +148,7 @@ impl TaskView {
]);

// Just preallocate capacity for ID, name, target, total, busy, and idle.
let mut overview = Vec::with_capacity(6);
let mut overview = Vec::with_capacity(7);
overview.push(Spans::from(vec![
bold("ID: "),
Span::raw(format!("{} ", task.id())),
Expand Down