Sleep()
What''s the function that does the same thing as sleep() in console? And what header does it require?
K I L A H M A N J A R O !
Wachar's Eternity <-<-<-<-<- Me own site!
sleep() is for wimps.
use caffeine() instead.
The header is <penguin_mints.h>
Ok... you can find sleep() in <unistd.h> on Unix platforms, Sleep() in <windows.h> and the deprecated _sleep() in <stdlib.h> on MS platforms.
Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost | STLport | FLTK | ACCU Recommended Books ]
use caffeine() instead.
The header is <penguin_mints.h>
Ok... you can find sleep() in <unistd.h> on Unix platforms, Sleep() in <windows.h> and the deprecated _sleep() in <stdlib.h> on MS platforms.
Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost | STLport | FLTK | ACCU Recommended Books ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Why thank you.
K I L A H M A N J A R O !
Wachar's Eternity <-<-<-<-<- Me own site!
quote:
Original post by Fruny
sleep() is for wimps.
use caffeine() instead.
too funny. :D
... I need a life.
[edited by - Militant on May 13, 2002 10:53:21 AM]
I'm not the brightest something or other in a group or similar.~ me ~
you could write your own sleep like:
#include <time.h> //i think that is the header...
int main()
{
clock_t sleep
sleep = clock() + 300;
while(sleep > clock());
return 0;
}
#include <time.h> //i think that is the header...
int main()
{
clock_t sleep
sleep = clock() + 300;
while(sleep > clock());
return 0;
}
Xier: Sleep() does not consume 100% CPU time, while your code does.
---visit #directxdev on afternet <- not just for directx, despite the name
On good multi-processing systems, if you lose control by sleeping for a small period of time (order of 10s of milliseconds or less) you can not ensure you will get a return within the bounds of the sleep parameter (eg. you go sleep for 10 ms. The computer returns control after 30 ms because it was busy with other processes).
So IndirectX, it''s possible that Xier''s code (or a nicer variation with much fine time determination) could be useful in some cases.
...just not if you sleep time is long (order of a 1 second or so).
So IndirectX, it''s possible that Xier''s code (or a nicer variation with much fine time determination) could be useful in some cases.
...just not if you sleep time is long (order of a 1 second or so).
Sleep() is good. If you''re making a graphics-intensive game, it''s a way to reduce your CPU use. Of course, your framerate takes a hit, but if you don''t want to make other programs run slowly and choppily, it''s a nice tool. You should call it with a small number to avoid losing too much processor though, say Sleep(1).
Later,
ZE.
//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links
[if you have a link proposal, email me.]
Later,
ZE.
//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links
[if you have a link proposal, email me.]
[twitter]warrenm[/twitter]
Yeah, thx.
K I L A H M A N J A R O !
Wachar's Eternity <-<-<-<-<- Me own site!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement