Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

timer_generic.cpp

Go to the documentation of this file.
00001 
00002 #include "Core/precomp.h"
00003 #include "API/Core/System/timer.h"
00004 #include "API/Core/System/system.h"
00005 
00006 CL_Timer::CL_Timer(unsigned long _interval)
00007 : interval(_interval), last_time(0), enabled(false)
00008 {
00009 }
00010 
00011 void CL_Timer::keep_alive()
00012 {
00013         if (!enabled)
00014                 return;
00015 
00016         unsigned long cur = CL_System::get_time();
00017         if (last_time > cur)
00018                 last_time = cur; // wrapped uint32
00019                 
00020         while (cur >= last_time + interval)
00021         {
00022                 sig_timer();
00023                 last_time += interval;
00024         }
00025 }
00026 
00027 void CL_Timer::enable()
00028 {
00029         enabled = true;
00030         last_time = CL_System::get_time();
00031 }
00032 
00033 void CL_Timer::disable()
00034 {
00035         enabled = false;
00036 }
00037 
00038 void CL_Timer::set_interval(unsigned long interval)
00039 {
00040         this->interval = interval;
00041         last_time = CL_System::get_time();
00042 }
00043 
00044 unsigned long CL_Timer::get_interval()
00045 {
00046         return interval;
00047 }

Generated at Wed Apr 4 19:54:04 2001 for ClanLib by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001