예제 #1
0
void
CompositorParent::ScheduleComposition()
{
  if (mCurrentCompositeTask || mPaused) {
    return;
  }

  bool initialComposition = mLastCompose.IsNull();
  TimeDuration delta;
  if (!initialComposition)
    delta = TimeStamp::Now() - mLastCompose;

  int32_t rate = CalculateCompositionFrameRate();

  // If rate == 0 (ASAP mode), minFrameDelta must be 0 so there's no delay.
  TimeDuration minFrameDelta = TimeDuration::FromMilliseconds(
    rate == 0 ? 0.0 : std::max(0.0, 1000.0 / rate));


  mCurrentCompositeTask = NewRunnableMethod(this, &CompositorParent::CompositeCallback);

  if (!initialComposition && delta < minFrameDelta) {
    TimeDuration delay = minFrameDelta - delta;
#ifdef COMPOSITOR_PERFORMANCE_WARNING
    mExpectedComposeStartTime = TimeStamp::Now() + delay;
#endif
    ScheduleTask(mCurrentCompositeTask, delay.ToMilliseconds());
  } else {
#ifdef COMPOSITOR_PERFORMANCE_WARNING
    mExpectedComposeStartTime = TimeStamp::Now();
#endif
    ScheduleTask(mCurrentCompositeTask, 0);
  }
}
예제 #2
0
void
CompositorParent::ScheduleComposition()
{
  if (mCurrentCompositeTask) {
    return;
  }

  bool initialComposition = mLastCompose.IsNull();
  TimeDuration delta;
  if (!initialComposition)
    delta = mozilla::TimeStamp::Now() - mLastCompose;

#ifdef COMPOSITOR_PERFORMANCE_WARNING
  mExpectedComposeTime = mozilla::TimeStamp::Now() + TimeDuration::FromMilliseconds(15);
#endif

  mCurrentCompositeTask = NewRunnableMethod(this, &CompositorParent::Composite);

  // Since 60 fps is the maximum frame rate we can acheive, scheduling composition
  // events less than 15 ms apart wastes computation..
  if (!initialComposition && delta.ToMilliseconds() < 15) {
#ifdef COMPOSITOR_PERFORMANCE_WARNING
    mExpectedComposeTime = mozilla::TimeStamp::Now() + TimeDuration::FromMilliseconds(15 - delta.ToMilliseconds());
#endif
    ScheduleTask(mCurrentCompositeTask, 15 - delta.ToMilliseconds());
  } else {
    ScheduleTask(mCurrentCompositeTask, 0);
  }
}
예제 #3
0
void Scheduler::operator()()
{
	// pull a task off the ready list
	if (!m_ReadyList.try_pop(m_CurrentTask)) {
		//std::cout <<"Scheduler::Step(), FAILED POP" << std::endl;
		m_CurrentTask = nullptr;

		// must continue at top of loop, since we don't have a task to process
		return;
	}

	if (m_CurrentTask->getStatus() == TASK_READY)
	{
		m_CurrentTask->resume();

		// check completion status
		// if it's still in a ready state, 
		// put it back on the ready list
		if (m_CurrentTask->getStatus() == TASK_READY) {
			ScheduleTask(m_CurrentTask);
		} else {
			//printf("Dropping task: %d\n", m_CurrentTask->getStatus());
		}
	}	
}
예제 #4
0
파일: NThreadPool.cpp 프로젝트: refnum/nano
//============================================================================
//		NThreadPool::Resume : Resume the pool.
//----------------------------------------------------------------------------
void NThreadPool::Resume(void)
{	StLock						acquireLock(mLock);
	NThreadTaskListIterator		theIter;



	// Validate our state
	NN_ASSERT(mIsPaused);



	// Schedule the tasks
	//
	// The threads are blocked until we release the lock, so any sorting
	// of the task list will be deferred until the first thread can run.
	for (theIter = mTasksPending.begin(); theIter != mTasksPending.end(); theIter++)
		ScheduleTask(*theIter);



	// Update our state
	mIsPaused = false;
	
	mTasksPending.clear();
}
NS_IMETHODIMP
FileSystemPermissionRequest::Cancel()
{
  MOZ_ASSERT(NS_IsMainThread());
  mTask->SetError(NS_ERROR_DOM_SECURITY_ERR);
  ScheduleTask();
  return NS_OK;
}
NS_IMETHODIMP
FileSystemPermissionRequest::Allow(JS::HandleValue aChoices)
{
  MOZ_ASSERT(NS_IsMainThread());
  MOZ_ASSERT(aChoices.isUndefined());
  ScheduleTask();
  return NS_OK;
}
BST_VOID BST_CTaskSchdler::TimerExpired(
    BST_OS_TIMERID_T    ulId,
    BST_VOID           *pvPara)
{
    BST_CORE_PTASK_NODE_STRU   *pstPtaskNode;
    BST_CORE_PTASK_NODE_STRU   *pstPtaskNodeNext;

    if ( !BST_OS_IsTimerValid (m_ulTimerId) )
    {
        BST_RLS_LOG1( "BST_CTaskSchdler::TimerExpired m_ulTimerId=%u is invalid",
                      m_ulTimerId );
        return;
    }
    if ( ulId != m_ulTimerId )
    {
        BST_RLS_LOG2( "BST_CTaskSchdler::TimerExpired ulId=%u,m_ulTimerId=%u",
                      ulId, m_ulTimerId );
        return;
    }
    /*
     * 如果没有任务,则直接返回,不做任何操作
     */
    if ( 0 == lstCount( &g_stPTaskList ) )
    {
        BST_RLS_LOG( "BST_CTaskSchdler::TimerExpired g_stPTaskList count=0" );
        return;
    }

    /*
     * 更新系统TICK值
     */
    m_ulSystemTick         += BST_TASK_SYS_TICKS;
    BST_DBG_LOG1 ( "BST_CTaskSchdler::TimerExpired Scheduler TimeOut, Tick=%d ",
                   m_ulSystemTick );

    /*
     * 遍历任务列表,获取任务并进行相应调度
     */
    for ( pstPtaskNode = ( BST_CORE_PTASK_NODE_STRU *)lstFirst( &g_stPTaskList );
          pstPtaskNode!= BST_NULL_PTR;
          pstPtaskNode = pstPtaskNodeNext )
    {
        pstPtaskNodeNext    = ( BST_CORE_PTASK_NODE_STRU *)
                              lstNext((NODE *)pstPtaskNode);
        if ( BST_NULL_PTR == pstPtaskNode->pcTask )
        {
            continue;
        }
        /*
         * 如果任务不为空,则根据状态进行调度
         */
        ScheduleTask ( pstPtaskNode->pcTask );
    }
    /*
     * 再次启动系统TICK定时器
     */
    BST_OS_TimerStart ( m_ulTimerId, BST_TASK_SYS_BASE_TIMELEN );
}
예제 #8
0
파일: NThreadPool.cpp 프로젝트: refnum/nano
//============================================================================
//		NThreadPool::AddTask : Add a task to the pool.
//----------------------------------------------------------------------------
void NThreadPool::AddTask(NThreadTask *theTask)
{	StLock	acquireLock(mLock);



	// Add the task
	if (mIsPaused)
		mTasksPending.push_back(theTask);
	else
		ScheduleTask(theTask);
}
예제 #9
0
void
CompositorParent::ScheduleRotationOnCompositorThread(const TargetConfig& aTargetConfig,
                                                     bool aIsFirstPaint)
{
  MOZ_ASSERT(IsInCompositorThread());

  if (!aIsFirstPaint &&
      !mCompositionManager->IsFirstPaint() &&
      mCompositionManager->RequiresReorientation(aTargetConfig.orientation())) {
    if (mForceCompositionTask != nullptr) {
      mForceCompositionTask->Cancel();
    }
    mForceCompositionTask = NewRunnableMethod(this, &CompositorParent::ForceComposition);
    ScheduleTask(mForceCompositionTask, gfxPrefs::OrientationSyncMillis());
  }
}
예제 #10
0
파일: scheduling.c 프로젝트: LuccoJ/z80sim
void DefaultScheduler() {
	if(LockQuery(SystemLock)) {
		Halt("SYSTEM LOCKED SCH");
		NullScheduler();
		return;
	}
        if(SystemTasks==NULL) Break("SCHEDULING NO TASK");
        if(CurrentTask==NULL) {
                CurrentTask=SystemTasks;
        } else {
                CurrentSP=&(CurrentTask->Value.SP);
		//if(CurrentSP==0) Halt("ERRONEOUS STACK POINPOINTER");
		//if(*CurrentSP<(void*)0x8000) for(;;); //Halt("ERRONEOUS STACK POINTER");
        }
	do {
        	if(CurrentTask->Next==NULL) {
                	CurrentTask=SystemTasks;
        	} else {
                	CurrentTask=CurrentTask->Next;
        	}
	} while(CurrentTask->Value.RegisteredEvents!=EVENT_RUNTASK);
        ScheduleTask(&(CurrentTask->Value));
}