Beispiel #1
0
wxString JobPoolWorker::GetStatus()
{
    wxString ret = wxString::Format("Thread: %X\n    ", GetId());
    if (currentJob != nullptr) {
        ret += currentJob->GetStatus();
    } else {
        ret += "<idle>";
    }
    return ret;
}
Beispiel #2
0
std::string JobPoolWorker::GetStatus()
{
    std::stringstream ret;
    ret << "Thread: ";
    
    
    ret << std::showbase // show the 0x prefix
        << std::internal // fill between the prefix and the number
        << std::setfill('0') << std::setw(10)
        << std::hex << GetId()
        << "    ";
    if (currentJob != nullptr) {
        ret << currentJob->GetStatus();
    } else {
        ret << "<idle>";
    }
    return ret.str();
}
Beispiel #3
0
/*!
 * This function refreshes the job list. It queries the server for the required
 * information and then updates the list control.
 *
 * \par Notes on the implementation of RefreshList()
 * For efficiency reasons, after the initial refresh, all refreshes are
 * incremental. Because IPC is the slowest part of the whole program the client
 * only gathers the only the information that is subject to have changed from
 * the server. The list control is also left alone during the process so that
 * it is greyed out for as short a period as possible.
 *
 * \par
 * The list control is also updated incrementally, yet for a completely
 * different reason. Whenever the list control is cleared entirely, it not only
 * takes time to reload the entire list, but it resets the current position of
 * the list in the scroller, so every time the client refreshes the user is
 * looking at the top (and most likely irrelevant) portion of the queue again.
 * 
 * \par
 * Due to the incremental nature of this code, it is rather complicated and
 * should be left alone, unless there is a good reason to change it.
 */
void GamessQFrame::RefreshList()
{
	int *ids = mQueueManager.GetJobIds();
	int num = ids[0];

	wxString name;
	int procs;
	Job::Status status;
	Job *job;

	// update any jobs that are out of date, and remove any jobs that no longer
	// exist on the server
    JobList::compatibility_iterator node = mJobList.GetFirst();
	int i = 1;
	while (node) {
		job = node->GetData();
		if (i <= num && job->GetId() == ids[i]) {
			// update the status
			status = job->GetStatus();
			if (status != Job::STATUS_DONE && status != Job::STATUS_ERROR
					&& status != Job::STATUS_CANCELED) {
				job->SetStatus(mQueueManager.GetStatus(ids[i]));
			}
			node = node->GetNext();
			i++;
		} else {
			JobList::compatibility_iterator nextNode = node->GetNext();
			mJobList.DeleteNode(node);
			node = nextNode;
		}
	}

	// add any new jobs for which we do not yet have local copies
	for (; i <= num; i++) {
		name = mQueueManager.GetName(ids[i]);
		procs = mQueueManager.GetNumProcessors(ids[i]);
		status = mQueueManager.GetStatus(ids[i]);
		job = new Job(ids[i], name, wxT(""), status, procs);
		mJobList.Append(job);
	}

	// update the interface
	jobListCtrl->Hide();

	// update the jobs that are in the control and delete any jobs that no
	// longer exist
	node = mJobList.GetFirst();
	i = 0;
	while (i < jobListCtrl->GetItemCount()) {
		if (node && jobListCtrl->GetItemData(i) == node->GetData()->GetId()) {
			jobListCtrl->SetItem(i, 0, node->GetData()->GetName());
			jobListCtrl->SetItem(i, 2, node->GetData()->GetStatusString());
			node = node->GetNext();
			i++;
		} else {
			jobListCtrl->DeleteItem(i);
		}
	}

	// add new entries to the control for the new jobs
	for (;node; i ++, node = node->GetNext()) {
		Job *job = node->GetData();
		int index = jobListCtrl->InsertItem(i, job->GetName());
		jobListCtrl->SetItemData(index, job->GetId());
		wxString procs;
		procs << job->GetNumProcessors();
		jobListCtrl->SetItem(index, 1, procs);
		jobListCtrl->SetItem(index, 2, job->GetStatusString());
	}
	jobListCtrl->Show();

	delete ids;
	mRefreshTimer->Start(mRefreshFrequency, wxTIMER_ONE_SHOT);
}