mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Start to hook this stuff up.
This commit is contained in:
@@ -68,7 +68,7 @@ void JobQueue::addJob(JobType type, const boost::function<void(Job&)>& jobFunc)
|
||||
boost::mutex::scoped_lock sl(mJobLock);
|
||||
assert(mThreadCount != 0); // do not add jobs to a queue with no threads
|
||||
|
||||
mJobSet.insert(Job(type, ++mLastJob, jobFunc));
|
||||
mJobSet.insert(Job(type, ++mLastJob, mJobLoads[type], jobFunc));
|
||||
++mJobCounts[type];
|
||||
mJobCond.notify_one();
|
||||
}
|
||||
@@ -108,6 +108,43 @@ std::vector< std::pair<JobType, int> > JobQueue::getJobCounts()
|
||||
return ret;
|
||||
}
|
||||
|
||||
Json::Value JobQueue::getJson(int)
|
||||
{
|
||||
Json::Value ret(Json::objectValue);
|
||||
boost::mutex::scoped_lock sl(mJobLock);
|
||||
|
||||
ret["threads"] = mThreadCount;
|
||||
|
||||
Json::Value priorities = Json::arrayValue;
|
||||
for (int i = 0; i < NUM_JOB_TYPES; ++i)
|
||||
{
|
||||
uint64 count, latencyAvg, latencyPeak, jobCount;
|
||||
mJobLoads[i].getCountAndLatency(count, latencyAvg, latencyPeak);
|
||||
std::map<JobType, int>::iterator it = mJobCounts.find(static_cast<JobType>(i));
|
||||
if (it == mJobCounts.end())
|
||||
jobCount = 0;
|
||||
else
|
||||
jobCount = it->second;
|
||||
if ((count != 0) || (jobCount != 0) || (latencyPeak != 0))
|
||||
{
|
||||
Json::Value pri(Json::objectValue);
|
||||
pri["priority_level"] = Job::toString(static_cast<JobType>(i));
|
||||
if (count != 0)
|
||||
pri["waiting"] = static_cast<int>(jobCount);
|
||||
if (jobCount != 0)
|
||||
pri["per_second"] = static_cast<int>(count);
|
||||
if (latencyPeak != 0)
|
||||
pri["peak_latency"] = static_cast<int>(latencyPeak);
|
||||
if (latencyAvg != 0)
|
||||
pri["avg_latency"] = static_cast<int>(latencyAvg);
|
||||
priorities.append(pri);
|
||||
}
|
||||
}
|
||||
ret["priorities"] = priorities;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void JobQueue::shutdown()
|
||||
{ // shut down the job queue without completing pending jobs
|
||||
cLog(lsINFO) << "Job queue shutting down";
|
||||
|
||||
Reference in New Issue
Block a user