1
0
Fork 0

Merge pull request #551 from worktycho/schedular

Implemented xoft's suggestion for a saturating counter in the scheduler
This commit is contained in:
Mattes D 2014-01-19 07:46:34 -08:00
commit 6976735a53
1 changed files with 2 additions and 6 deletions

View File

@ -871,16 +871,11 @@ void cWorld::TickScheduledTasks()
// Make a copy of the tasks to avoid deadlocks on accessing m_Tasks
{
cCSLock Lock(m_CSScheduledTasks);
ScheduledTaskList::iterator itr = m_ScheduledTasks.begin();
while (itr != m_ScheduledTasks.end() && (*itr)->Ticks > 0)
while (!m_ScheduledTasks.empty() && m_ScheduledTasks.front()->Ticks < m_WorldAge)
{
Tasks.push_back(m_ScheduledTasks.front());
m_ScheduledTasks.pop_front();
}
for(;itr != m_ScheduledTasks.end(); itr++)
{
(*itr)->Ticks--;
}
}
// Execute and delete each task:
@ -2634,6 +2629,7 @@ void cWorld::QueueTask(cTask * a_Task)
void cWorld::ScheduleTask(cScheduledTask * a_Task)
{
a_Task->Ticks = a_Task->Ticks + m_WorldAge;
cCSLock Lock(m_CSScheduledTasks);
for(ScheduledTaskList::iterator itr = m_ScheduledTasks.begin(); itr != m_ScheduledTasks.end(); itr++)
{