Esempio n. 1
0
bool BProcess::ScheduleNextEvent()
{
//	bout << "BProcess::ScheduleNextEvent (" << SysCurrentThread() << ")@" << SysGetRunTime() << endl;

    // Don't schedule the next event if it would introduce too much concurrency.
    // XXX TO DO -- need to allow scheduling the next event if all currently
    // running handlers are blocked.
    if (m_currentEventConcurrency >= m_maxEventConcurrency) {
        return false;
    }

    int32_t priority = B_NORMAL_PRIORITY;
    const nsecs_t nextTime	= m_pendingHandlers
                              ? m_pendingHandlers->NextMessageTime(&priority)
                              : B_INFINITE_TIMEOUT;

    if (nextTime < m_nextEventTime) {
#if 0
        bout << "Setting next event time: from " << m_nextEventTime << " to " << nextTime
             << " (" << (nextTime-SysGetRunTime()) << " from now)" << endl;
#endif
        m_nextEventTime = nextTime;
        return SLooper::_SetNextEventTime(m_nextEventTime, sysThreadPriorityBestUser);
    }

    return false;
}
Esempio n. 2
0
void fastPoll( void )
	{
	RANDOM_STATE randomState;
	BYTE buffer[ RANDOM_BUFSIZE + 8 ];
	WinHandle winHandle;
	Coord xCoord, yCoord;
	Boolean flag;
	uint64_t ticks;
	nsecs_t nsTime;

	initRandomData( randomState, buffer, RANDOM_BUFSIZE );

	/* Get the event-available and low-level event-available flag, current
	   pen status, and handle of the window with the input focus */
	flag = EvtEventAvail();
	addRandomValue( randomState, flag );
	flag = EvtSysEventAvail( TRUE );
	addRandomValue( randomState, flag );
	EvtGetPen( &xCoord, &yCoord, &flag );
	addRandomValue( randomState, xCoord );
	addRandomValue( randomState, yCoord );
	winHandle = EvtGetFocusWindow();
	addRandomValue( randomState, winHandle );

	/* Get the number of ticks of the (software) millisecond clock used
	   by the scheduler, and the length of time in nanoseconds since the
	   last reset */
	ticks = TimGetTicks();
	addRandomData( randomState, &ticks, sizeof( uint64_t ) );
	nsTime = SysGetRunTime();
	addRandomData( randomState, &nsTime, sizeof( nsecs_t ) );

	/* Get the value of the real-time and runtime clocks in nanoseconds.
	   One of these may just be a wrapper for SysGetRunTime(), in addition
	   it's likely that they're hardware-specific, being CPU-level cycle
	   counters of some kind */
	nsTime = system_real_time();
	addRandomData( randomState, &nsTime, sizeof( nsecs_t ) );
	nsTime = system_time();
	addRandomData( randomState, &nsTime, sizeof( nsecs_t ) );

	/* Flush any remaining data through */
	endRandomData( randomState, 5 );
	}