本文整理汇总了C++中JobPtr类的典型用法代码示例。如果您正苦于以下问题:C++ JobPtr类的具体用法?C++ JobPtr怎么用?C++ JobPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JobPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lock
std::string
JobQueue::toString()
{
stringstream ss;
IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
if ( activeJobCount_ )
ss<<"ACTIVE JOBS (maybe out of sync):"<<endl;
for ( size_t i=0; i<workerPool_.size(); ++i )
{
string s;
if ( workerPool_[i] )
{
WorkerPtr w = WorkerPtr::dynamicCast( workerPool_[i] );
s = w->toString();
if ( !s.empty() )
ss << " " << w->toString() << endl;
}
}
if ( !pendingJobs_.empty() )
ss<<"PENDING JOBS:"<<endl;
for ( std::list<JobPtr>::const_iterator it=pendingJobs_.begin(); it!=pendingJobs_.end(); ++it ) {
const JobPtr job = *it;
ss << " " << job->toString() << endl;
}
return ss.str();
}
示例2: growStats
bool StatSystem::growStats(JobPtr job, int multiplier)
{
set<StatPtr> statSet = job->getGrowthStats();
for(StatPtr stat:statSet)
{
auto isStatSame = [&] (StatPtr statPtr)
{
return *statPtr == *stat;
};
auto statItr = find_if(calculatedStats.begin(),
calculatedStats.end(),
isStatSame);
if(statItr == calculatedStats.end())
{
auto statBase = job->getBaseStats();
auto baseIter = statBase.find(stat);
StatPtr foundBase = *baseIter;
calculatedStats.insert(foundBase);
statItr = calculatedStats.find(stat);//Review this> Unnecesary find?
}
StatPtr foundStat = *statItr;
int growth = stat->getDefaultNumber();
foundStat->grow(growth * multiplier);
}
return true;
}
示例3: backupJob
void JobsTabWidget::backupJob(JobPtr job)
{
if(!job)
return;
if(!job->validateUrls())
{
if(job->urls().isEmpty())
{
QMessageBox::warning(this, tr("Job error"),
tr("Job %1 has no backup paths selected. "
"Nothing to back up.")
.arg(job->name()));
return;
}
else
{
QMessageBox::StandardButton confirm = QMessageBox::question(
this, tr("Job warning"),
tr("Some backup paths for Job %1 are not"
" accessible anymore and thus backup may"
" be incomplete."
" Proceed with backup?")
.arg(job->name()));
if(confirm != QMessageBox::Yes)
return;
}
}
emit backupNow(job->createBackupTask());
}
示例4: execDeleteJob
void JobListWidget::execDeleteJob(JobListWidgetItem *jobItem)
{
if(!jobItem)
{
DEBUG << "Null JobListWidgetItem passed.";
return;
}
JobPtr job = jobItem->job();
QMessageBox::StandardButton confirm =
QMessageBox::question(this, tr("Confirm action"),
tr("Are you sure you want to delete job \"%1\" "
"(this cannot be undone)?")
.arg(job->name()));
if(confirm != QMessageBox::Yes)
return;
bool purgeArchives = false;
if(!job->archives().isEmpty())
{
QMessageBox::StandardButton delArchives =
QMessageBox::question(this, tr("Confirm action"),
tr("Also delete %1 archives "
"belonging to this job "
"(this cannot be undone)?")
.arg(job->archives().count()));
if(delArchives == QMessageBox::Yes)
purgeArchives = true;
}
emit deleteJob(job, purgeArchives);
delete jobItem;
emit countChanged(count(), visibleItemsCount());
}
示例5: HandleTaskExecute
void Peer::HandleTaskExecute(MessagePtr pMsg)
{
bool status = true;
PeerNodePtr pPeer = pMsg->m_conn->GetPeerNode();
JobPtr pJob = this->GetJob(pMsg->m_fromPeerId, pMsg->m_taskId, pPeer);
if(pJob == NULL) {
Log(ERR, L"Peer::HandleTaskExecute- Task Execute request received for Non-Existing Job from Peer: %d, taskid: %d\n",
pMsg->m_fromPeerId, pMsg->m_taskId);
status = false;
}
else {
Log(CONSOLE, L"Handling Task Execute from Peer: %d, taskid: %d\n",
pMsg->m_fromPeerId, pMsg->m_taskId);
// start the job
pJob->SetPeerNode(pMsg->m_conn->GetPeerNode());
int result = pJob->Start();
//[TODO] handle job failure to execute
if(result < 0) {
Log(ERR, L"Peer::HandleTaskExecute- Task Execute request could not be completed from Peer: %d, taskid: %d\n",
pMsg->m_fromPeerId, pMsg->m_taskId);
status = false;
}
}
// send response
PeerNodePtr pNode = pMsg->m_conn->GetPeerNode();
pNode->TaskExecuteResponse(pMsg->m_taskId, status);
}
示例6: if
JobPtr Peer::GetJob(int peerId, int taskId, PeerNodePtr pNode)
{
std::map<int, JobPtr>::iterator it;
for(it = m_jobList.begin(); it != m_jobList.end(); it++) {
JobPtr pJob = (*it).second;
if(pJob->GetTaskId() == taskId && pJob->GetRemotePeerId() == peerId)
if(pNode == NULL)
return pJob;
else if(pNode == pJob->GetPeerNode())
return pJob;
}
return JobPtr();
}
示例7: newJob
Job::JobPtr Job::newJob(const string& name) {
JobPtr tmp;
std::unique_lock<mutex> lock(globalJobMutex);
auto it = getMap().find(boost::to_upper_copy(name));
if(it != getMap().end()) {
tmp.reset(it->second.second());
} else {
#ifdef DEBUG__
cerr << "No job with tag \"" << name << "\" registered." << endl;
#endif
}
return tmp;
}
示例8: AddJobToPrivilegeQueue
bool GroupPool::AddJobToPrivilegeQueue(const JobPtr& job, bool push_front) {
WriteLocker locker(m_privilege_job_queue_lock);
// TODO test
if (!FindByName(job->GetGroupName())) {
LOG4CPLUS_ERROR(logger, "No this group, group name: " << job->GetGroupName());
return false;
}
printf("privilege!\n");
if (push_front)
m_privilege_wait_job_queue.push_front(job);
else
m_privilege_wait_job_queue.push_back(job);
return true;
}
示例9: CondVarPtr
msg_t *Scheduler::concurrentHandler(msg_t &request, msg_t &response,
unsigned long sizeBytes) {
auto jCondVar = CondVarPtr(new boost::condition_variable);
boost::mutex jobMutex;
boost::unique_lock<boost::mutex> lock(jobMutex);
auto jInfo = JobInfoPtr(new JobInfo());
jInfo->setFinished(false);
jInfo->setStarted(false);
JobPtr nJob = JobPtr(new Job(&request, getNextId()));
JobTuple t = std::make_tuple(nJob, jInfo, jCondVar);
JobTuplePtr jobPtr = std::make_shared<JobTuple>(t);
std::get<0>(*jobPtr)->setIssueTime(bc::system_clock::now());
readyQ->push_front(jobPtr);
// LOGF(debug, " New conn tid = %1%, Added job to readyQ %2%")
// % boost::this_thread::get_id() % *nJob;
try {
while (!jInfo->isFinished()) {
jCondVar->wait(lock);
}
lock.unlock();
// LOG(debug) << *nJob << " finished";
msg_t *rsp = nJob->getRsp();
if (rsp == NULL) {
// ERROR
} else {
response.msgId = rsp->msgId;
response.dataSize = rsp->dataSize;
response.paramsSize = 0;
response.totalBytes = rsp->totalBytes;
response.dataBytes = rsp->dataBytes;
memcpy(&response.data, rsp->data, rsp->dataBytes);
free(rsp);
}
}
catch (boost::thread_interrupted &) {
// LOG(debug) << "Concurrent handler interrupted";
return &response;
}
#ifdef DEBUG
response.print();
#endif
return &response;
}
示例10: put
//////////////////////////////////////////////////////////////////////
// Jobqueue
//
void Jobqueue::put(JobPtr& j, bool force)
{
j->touch();
cxxtools::MutexLock lock(_mutex);
if (!force && _capacity > 0)
{
while (_jobs.size() >= _capacity)
{
log_warn("Jobqueue full");
_notFull.wait(lock);
}
}
_jobs.push_back(j);
// We have to drop ownership before releasing the lock of the queue.
// Therefore we set the smart pointer to 0.
j = 0;
if (_waitThreads == 0)
noWaitThreads.signal();
_notEmpty.signal();
}
示例11: AddJobToWaitQueue
// add job to wait queue
bool GroupPool::AddJobToWaitQueue(const JobPtr& job) {
int priority = job->GetRawPriority();
if (JOB_RAW_PRIO_PRIVILEGE == priority) {
if (!AddJobToPrivilegeQueue(job)) {
LOG4CPLUS_ERROR(logger, "Failed to AddJobToPrivilegeQueue.");
return false;
}
} else {
if (!AddJobToWaitQueueByGroup(job)) {
// test
printf("No this group, %s\n", job->GetGroupName().c_str());
LOG4CPLUS_ERROR(logger, "No this group, group name: " << job->GetGroupName());
return false;
}
}
return true;
}
示例12: restoreItem
void JobListWidget::restoreItem()
{
if(sender())
{
JobPtr job = qobject_cast<JobListWidgetItem *>(sender())->job();
if(!job->archives().isEmpty())
{
ArchivePtr archive = job->archives().first();
RestoreDialog *restoreDialog = new RestoreDialog(this, archive);
restoreDialog->show();
connect(restoreDialog, &RestoreDialog::accepted, [=] {
emit restoreArchive(restoreDialog->archive(),
restoreDialog->getOptions());
});
}
}
}
示例13: HandleTaskCancel
void Peer::HandleTaskCancel(MessagePtr pMsg)
{
bool status = true;
JobPtr pJob = this->GetJob(pMsg->m_fromPeerId, pMsg->m_taskId);
if(pJob == NULL) {
Log(ERR, L"Peer::HandleTaskCancel- Task Cancel request received for Non-Existing Job from Peer: %d, taskid: %d\n",
pMsg->m_fromPeerId, pMsg->m_taskId);
status = false;
}
else {
Log(CONSOLE, L"Handling Task Cancel from Peer: %d, taskid: %d\n", pMsg->m_fromPeerId, pMsg->m_taskId);
// cancel the job
pJob->Stop();
m_jobList.erase(pJob->GetJobId());
}
}
示例14: while
bool JobQueueWorker::operator()()
{
logger_ = &log4cpp::Category::getInstance("JobQueueWorker(" + boost::lexical_cast<std::string>(boost::this_thread::get_id()) + ")");
while (true)
{
/*
* Get the next work item to do
*/
JobPtr job = queue_.dequeue();
if (!job)
return true;
logger_->debug("beginning job");
job->run();
logger_->debug("finished job");
}
}
示例15:
bc::duration<double> Scheduler::estimateExecutionTime(JobPtr j) {
// TODO[mtottenh]:Add code to estimate a job finish time
double milliseconds = (double)j->getReq()->predictedTimeMillis;
bc::duration<double, boost::ratio<1, 1000> > milli_sec(milliseconds);
auto micro_sec = bc::duration_cast<bc::microseconds>(milli_sec);
// LOG(debug) << milli_sec.count() << "ms"
// << ", " << micro_sec.count() << "us";
return milli_sec;
}