00001 /* 00002 * The Mana World Server 00003 * Copyright 2004 The Mana World Development Team 00004 * 00005 * This file is part of The Mana World. 00006 * 00007 * The Mana World is free software; you can redistribute it and/or modify it 00008 * under the terms of the GNU General Public License as published by the Free 00009 * Software Foundation; either version 2 of the License, or any later version. 00010 * 00011 * The Mana World is distributed in the hope that it will be useful, but 00012 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 00013 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 00014 * more details. 00015 * 00016 * You should have received a copy of the GNU General Public License along 00017 * with The Mana World; if not, write to the Free Software Foundation, Inc., 00018 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 */ 00020 00021 #ifndef _TMWSERV_TIMER_H_ 00022 #define _TMWSERV_TIMER_H_ 00023 00024 /* I need a 64-bit unsigned integer */ 00025 #ifdef _MSC_VER 00026 typedef __uint64 uint64_t // when using MSVC use its internal type 00027 #else 00028 #include <stdint.h> // on other compilers use the C99 official header 00029 #endif 00030 00031 namespace utils 00032 { 00033 00037 class Timer 00038 { 00039 public: 00043 Timer(unsigned int ms, bool createActive = true); 00044 00048 int poll(); 00049 00053 void sleep(); 00054 00058 void start(); 00059 00063 void stop(); 00064 00068 void changeInterval (unsigned int newinterval); 00069 00070 private: 00074 uint64_t getTimeInMillisec(); 00075 00079 unsigned int interval; 00080 00084 uint64_t lastpulse; 00085 00089 bool active; 00090 }; 00091 00092 } // ::utils 00093 00094 #endif