Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*==================================================================================================
- --------------------------------------------------------------------------------------------------
- [slowTime.h]
- The CSlowTime class definition, used to allow the CPU to slow down its processing power.
- The class provides one function used to allow the CPU to loop processes as if it were asleep for a
- short time.
- (c) Damion 'Phr0z3n.dev' Tapper, 2015.
- Email: [email protected]
- Website: L337Stuff.Blogspot.com
- --------------------------------------------------------------------------------------------------
- ==================================================================================================*/
- #ifndef SLOWTIME_H
- #define SLOWTIME_H
- #include <ctime>
- class CSlowTime
- {
- public:
- /**
- * sleep(): puts the CPU to work for a little before continuing normal process.
- *
- * ms: a positive integer that represents the number of milliseconds that the system should sleep.
- */
- void sleep(unsigned int ms)
- {
- clock_t goal = ms + clock();
- while(goal > clock()); // constant looping until time is up
- return; // successful processing
- }
- };
- #endif // SLOWTIME_H
Advertisement
Add Comment
Please, Sign In to add comment