コード例 #1
0
ファイル: timer.cpp プロジェクト: mordimerr/Ray
void FPS::Update()
{
	Delta_Time = World_Time;                  // Pobieramy wczeœniejszy czas

	World_Time = glfwGetTime() * 1000;        // Uaktualnienie czasu

	updates++;                                // Naliczenie aktualizcji

	// Blokada klatek
	if(max > 0)
	{
	  if( World_Time - Start_Time < ( 1000.0f / max ) * updates )            // Jeœli dotychczasowy czas jest mniejszy ni¿ zak³adany 
	  {
		  SleepFor( ( (1000.0f / max) * updates ) - ( World_Time - Start_Time)  );     // Odczekuje ró¿nicê czasów
	  }
	}

	World_Time = glfwGetTime() * 1000;              // Uaktualnia czas po odczekiwaniu ró¿nicy

	Delta_Time = World_Time - Delta_Time;           // Oblicza delte

	if( updates == frames)                          // Sprawdza iloϾ klatek
	{
		rate = ( 1000 * frames ) / ( World_Time - Start_Time);      // Oblicza œredni wynik klatek na sekundê
		World_Time = glfwGetTime() * 1000;                          // Wszystko resetuje
        Start_Time = glfwGetTime() * 1000;
        updates=0;
	}
}
コード例 #2
0
ファイル: price.cpp プロジェクト: systemtrader/ctpTrading
void price::thread_work()
{
	show_instruments();
	while (true)
	{
		SleepFor(1000);
		_Get_Output_Mutex
		chg_price();
		_Release_Output_Mutex
	}
}
コード例 #3
0
ファイル: System.cpp プロジェクト: Kangz/Unvanquished
SteadyClock::time_point SleepUntil(SteadyClock::time_point time) {
    // Early exit if we are already past the deadline
    auto now = SteadyClock::now();
    if (now >= time) {
        // We were already past our deadline, which means that the previous frame
        // ran for too long. Use the current time as the base for the next frame.
        return now;
    }

    // Perform the actual sleep
    SleepFor(time - now);

    // We may have overslept, so use the target time rather than the
    // current time as the base for the next frame. That way we ensure
    // that the frame rate remains consistent.
    return time;
}