Server: add optional size_class parameter to count_unsent_results().

This lets you write work generators that maintain min levels of
unsent jobs for each size class.
This commit is contained in:
David Anderson 2014-02-20 13:44:56 -08:00
parent 503b481548
commit 0d8a22e75c
2 changed files with 11 additions and 10 deletions

View File

@ -273,17 +273,18 @@ int count_workunits(int& n, const char* query) {
return workunit.count(n, query);
}
int count_unsent_results(int& n, int appid) {
char buf[256];
int count_unsent_results(int& n, int appid, int size_class) {
char query[1024], buf[256];
sprintf(query, "where server_state<=%d", RESULT_SERVER_STATE_UNSENT);
if (appid) {
sprintf(buf, "where server_state<=%d and appid=%d ",
RESULT_SERVER_STATE_UNSENT, appid
);
} else {
sprintf(buf, "where server_state<=%d", RESULT_SERVER_STATE_UNSENT);
sprintf(buf, " and appid=%d", appid);
strcat(query, buf);
}
return count_results(buf, n);
if (size_class >= 0) {
sprintf(buf, " and size_class=%d", size_class);
strcat(query, buf);
}
return count_results(query, n);
}
bool is_arg(const char* x, const char* y) {

View File

@ -72,7 +72,7 @@ struct PERF_INFO {
extern int mylockf(int fd);
extern int count_workunits(int&, const char* query);
extern int count_unsent_results(int&, int appid);
extern int count_unsent_results(int&, int appid, int size_class=-1);
// Return a value for host_app_version.app_version_id.
// if the app version is anonymous platform,