本文整理汇总了C++中internaljob::Pointer::Previous方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::Previous方法的具体用法?C++ Pointer::Previous怎么用?C++ Pointer::Previous使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类internaljob::Pointer
的用法示例。
在下文中一共展示了Pointer::Previous方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsBlocking
bool JobManager::IsBlocking(InternalJob::Pointer sptr_runningJob)
{
{
Poco::ScopedLock<Poco::Mutex> lockMe (m_mutex);
// if this job isn't running, it can't be blocking anyone
if (sptr_runningJob->GetState() != Job::RUNNING)
return false;
// if any job is queued behind this one, it is blocked by it
InternalJob::Pointer ptr_previous = sptr_runningJob->Previous();
while (ptr_previous != 0)
{
// ignore jobs of lower priority (higher priority value means lower priority)
if (ptr_previous->GetPriority() < sptr_runningJob->GetPriority())
{
if (!ptr_previous->IsSystem())
return true;
// TODO Implicit Jobs
// implicit jobs should interrupt unless they act on behalf of system jobs
// if (previous instanceof ThreadJob && ((ThreadJob) previous).shouldInterrupt())
// return true;
}
ptr_previous = ptr_previous->previous;
}
// none found
return false;
}
}
示例2: Enqueue
void JobQueue::Enqueue(InternalJob::Pointer newEntry)
{
InternalJob::Pointer tail = dummy->Next();
//overtake lower priority jobs. Only overtake conflicting jobs if allowed to
while (CanOvertake(newEntry, tail))
tail = tail->Next();
InternalJob::Pointer tailPrevious = tail->Previous();
newEntry->SetNext(tail);
newEntry->SetPrevious(tailPrevious);
tailPrevious->SetNext(newEntry);
tail->SetPrevious(newEntry);
}
示例3: ChangeState
void JobManager::ChangeState(InternalJob::Pointer sptr_job, int newState)
{
bool blockedJobs = false;
{
Poco::ScopedLock<Poco::Mutex> m_managerLock(m_mutex);
int tmp_oldState = sptr_job->InternalGetState();
switch (tmp_oldState)
{
case Job::NONE:
case InternalJob::ABOUT_TO_SCHEDULE:
break;
case InternalJob::BLOCKED:
//remove this job from the linked list of blocked jobs
sptr_job->Remove();
break;
case Job::WAITING:
m_JobQueueWaiting.Remove(sptr_job);
// assert(false, "Tried to remove a job that wasn't in the queue");
break;
case Job::SLEEPING:
m_JobQueueSleeping.Remove(sptr_job);
// assert(false, "Tried to remove a job that wasn't in the queue");
case Job::RUNNING:
case InternalJob::ABOUT_TO_RUN:
m_running.remove(sptr_job);
//add any blocked jobs back to the wait queue
InternalJob::Pointer sptr_blocked(sptr_job->Previous());
sptr_job->Remove();
blockedJobs = sptr_blocked != 0;
while (sptr_blocked != 0)
{
InternalJob::Pointer previous = sptr_blocked->Previous();
ChangeState(sptr_blocked, Job::WAITING);
sptr_blocked = previous;
}
break;
// default :
// Assert.isLegal(false, "Invalid job state: " + job + ", state: " + oldState);
}
sptr_job->InternalSetState(newState);
switch (newState)
{
case Job::NONE:
sptr_job->SetStartTime(InternalJob::T_NONE);
sptr_job->SetWaitQueueStamp(InternalJob::T_NONE);
case InternalJob::BLOCKED:
break;
case Job::WAITING:
m_JobQueueWaiting.Enqueue(sptr_job);
break;
case Job::SLEEPING:
//try {
m_JobQueueSleeping.Enqueue(sptr_job);
//} catch (RuntimeException e) {
// throw new RuntimeException("Error changing from state: " + oldState);
//}
break;
case Job::RUNNING:
case InternalJob::ABOUT_TO_RUN:
sptr_job->SetStartTime(InternalJob::T_NONE);
sptr_job->SetWaitQueueStamp(InternalJob::T_NONE);
m_running.insert(sptr_job);
break;
case InternalJob::ABOUT_TO_SCHEDULE:
break;
// default :
// Assert.isLegal(false, "Invalid job state: " + job + ", state: " + newState);
}
}
//notify queue outside sync block
if (blockedJobs)
m_Pool->JobQueued();
}