Example #1
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 );
	}
Example #2
0
Err PrvProcessEvents(FlickrSocketContext& context, UInt16 timeout)
{
    Err err = errNone;
    EventType event;

    if (timeout || EvtEventAvail())
    {
        EvtGetEvent(&event, timeout);
        if (!FlickrHandleEvent(context.libRefNum, &event) && NULL != context.progress)
            PrgHandleEvent(context.progress, &event);  // update progress before waiting...
    }
    else if (NULL != context.progress)
        PrgHandleEvent(context.progress, NULL);  // update progress without event (for animation)

    if (NULL != context.progress)
    {
        err = context.progress->error;
        // check for a user cancel and handle it...
        if (PrgUserCancel(context.progress))
            err = exgErrUserCancel;
    }
    return err;
}