Phr0zen_Penguin

slowTime.h

Feb 17th, 2015
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.24 KB | None | 0 0
  1. /*==================================================================================================
  2.   --------------------------------------------------------------------------------------------------
  3.   [slowTime.h]
  4.   The CSlowTime class definition, used to allow the CPU to slow down its processing power.
  5.  
  6.   The class provides one function used to allow the CPU to loop processes as if it were asleep for a
  7.   short time.
  8.  
  9.         (c) Damion 'Phr0z3n.dev' Tapper, 2015.
  10.         Email: [email protected]
  11.         Website: L337Stuff.Blogspot.com
  12.   --------------------------------------------------------------------------------------------------
  13.   ==================================================================================================*/
  14. #ifndef SLOWTIME_H
  15. #define SLOWTIME_H
  16.  
  17. #include <ctime>
  18.  
  19. class CSlowTime
  20. {
  21.     public:
  22.         /**
  23.          * sleep(): puts the CPU to work for a little before continuing normal process.
  24.          *
  25.          * ms: a positive integer that represents the number of milliseconds that the system should sleep.
  26.          */
  27.         void sleep(unsigned int ms)
  28.         {
  29.             clock_t goal = ms + clock();
  30.  
  31.                 while(goal > clock());      // constant looping until time is up
  32.  
  33.             return;                         // successful processing
  34.         }
  35. };
  36.  
  37. #endif // SLOWTIME_H
Advertisement
Add Comment
Please, Sign In to add comment