mirror of https://github.com/BOINC/boinc.git
client: show projects in alphabetical order of project name
A while back I changed the job sched and work fetch policies to use REC-based project priority. The work fetch logic sorts the project list (in CLIENT_STATE::projects) by descending priority. This causes two problems: - If you have a lot of projects, it's hard to find a particular one in the event log, e.g. in work_fetch_debug output. - In the manager's Statistics tab, the selected project can change unexpectedly since we identify it by array index, and the array order may change. Solution: sort CLIENT_STATE::projects alphabetically (case insensitive). In WORK_FETCH, copy this array to a separate array, that is then sorted by decreasing priority.
This commit is contained in:
parent
a6d20fe95e
commit
ef22b2bd4b
|
@ -77,6 +77,7 @@ using std::vector;
|
|||
struct CLIENT_STATE {
|
||||
vector<PLATFORM> platforms;
|
||||
vector<PROJECT*> projects;
|
||||
// in alphabetical order, to improve display
|
||||
vector<APP*> apps;
|
||||
vector<FILE_INFO*> file_infos;
|
||||
vector<APP_VERSION*> app_versions;
|
||||
|
@ -456,6 +457,7 @@ struct CLIENT_STATE {
|
|||
int write_file_transfers_gui(MIOFILE&);
|
||||
int write_tasks_gui(MIOFILE&, bool);
|
||||
void sort_results();
|
||||
void sort_projects();
|
||||
|
||||
// --------------- cs_trickle.cpp:
|
||||
int read_trickle_files(PROJECT*, FILE*);
|
||||
|
|
|
@ -353,6 +353,7 @@ int CLIENT_STATE::parse_account_files() {
|
|||
}
|
||||
}
|
||||
}
|
||||
sort_projects();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -574,6 +575,7 @@ int CLIENT_STATE::add_project(
|
|||
retval = make_project_dir(*project);
|
||||
if (retval) return retval;
|
||||
projects.push_back(project);
|
||||
sort_projects();
|
||||
project->sched_rpc_pending = RPC_REASON_INIT;
|
||||
set_client_state_dirty("Add project");
|
||||
return 0;
|
||||
|
|
|
@ -568,6 +568,18 @@ void CLIENT_STATE::sort_results() {
|
|||
}
|
||||
}
|
||||
|
||||
static inline bool project_name_compare(PROJECT* p0, PROJECT* p1) {
|
||||
return strcasecmp(p0->project_name, p1->project_name) < 0;
|
||||
}
|
||||
|
||||
void CLIENT_STATE::sort_projects() {
|
||||
std::sort(
|
||||
projects.begin(),
|
||||
projects.end(),
|
||||
project_name_compare
|
||||
);
|
||||
}
|
||||
|
||||
#ifndef SIM
|
||||
|
||||
// Write the client_state.xml file
|
||||
|
|
|
@ -517,8 +517,8 @@ void WORK_FETCH::piggyback_work_request(PROJECT* p) {
|
|||
}
|
||||
if (check_higher_priority_projects) {
|
||||
PROJECT* p2 = NULL;
|
||||
for (unsigned int j=0; j<gstate.projects.size(); j++) {
|
||||
p2 = gstate.projects[j];
|
||||
for (unsigned int j=0; j<projects_sorted.size(); j++) {
|
||||
p2 = projects_sorted[j];
|
||||
if (p2 == p) break;
|
||||
if (p2->sched_priority == p->sched_priority) continue;
|
||||
if (p2->pwf.project_reason) {
|
||||
|
@ -627,9 +627,10 @@ void WORK_FETCH::setup() {
|
|||
}
|
||||
}
|
||||
|
||||
projects_sorted = gstate.projects;
|
||||
std::sort(
|
||||
gstate.projects.begin(),
|
||||
gstate.projects.end(),
|
||||
projects_sorted.begin(),
|
||||
projects_sorted.end(),
|
||||
higher_priority
|
||||
);
|
||||
if (log_flags.work_fetch_debug) {
|
||||
|
@ -657,8 +658,8 @@ PROJECT* WORK_FETCH::choose_project() {
|
|||
// scan projects in order of decreasing priority
|
||||
//
|
||||
bool found = false;
|
||||
for (unsigned int j=0; j<gstate.projects.size(); j++) {
|
||||
p = gstate.projects[j];
|
||||
for (unsigned int j=0; j<projects_sorted.size(); j++) {
|
||||
p = projects_sorted[j];
|
||||
WF_DEBUG(msg_printf(p, MSG_INFO, "scanning");)
|
||||
if (p->pwf.project_reason) {
|
||||
WF_DEBUG(msg_printf(p, MSG_INFO, "skip: cfwr %d", p->pwf.project_reason);)
|
||||
|
|
|
@ -299,6 +299,8 @@ struct PROJECT_WORK_FETCH {
|
|||
// global work fetch state
|
||||
//
|
||||
struct WORK_FETCH {
|
||||
std::vector<PROJECT*> projects_sorted;
|
||||
// projects in decreasing priority order
|
||||
void setup();
|
||||
PROJECT* choose_project();
|
||||
// Find a project to ask for work.
|
||||
|
|
Loading…
Reference in New Issue