How to "sleep" or "delay"?

J

John

Thanks.

I am writing a C++ code on Linux and Sun OS platform.
How to make a procedure sleep or delay?

Thanks again.
 
J

Julie

John said:
Thanks.

I am writing a C++ code on Linux and Sun OS platform.
How to make a procedure sleep or delay?

Thanks again.

If you are looking for a platform-specific solution, you will need to post your
question in a newsgroup that responds to platform-specific posts.

I posted a platform-neutral version in response to your first inquiry. Any
particular reason that won't work for you?
 
J

John

Thanks. I just read it. Due to the up to 9 hours delay of posting, I
post my question before I saw your response. :)

John
 
J

John Carson

Julie said:
I posted a platform-neutral version in response to your first
inquiry. Any particular reason that won't work for you?

(The other) John seems happy, but your solution will drive CPU usage up to
100% (it does on Windows anyway), just so the program can do nothing.
Personally, I would much prefer a platform specific solution that actually
puts the thread to sleep.
 
J

Jorge Rivera

John said:
(The other) John seems happy, but your solution will drive CPU usage up to
100% (it does on Windows anyway), just so the program can do nothing.
Personally, I would much prefer a platform specific solution that actually
puts the thread to sleep.

I can't remember all the details, but I beleive that you can set an
"alarm" (look in the signals documentationon your Unix implementation).
Also, there is nanosleep. All you have to do is convert your time to
the appropriate nanosleep compatible time structure, and you will sleep
for that amount of nanoseconds.

JLR
 
J

Julie

Jorge said:
I can't remember all the details, but I beleive that you can set an
"alarm" (look in the signals documentationon your Unix implementation).
Also, there is nanosleep. All you have to do is convert your time to
the appropriate nanosleep compatible time structure, and you will sleep
for that amount of nanoseconds.

JLR

Yes, but that isn't platform neutral and/or portable.

The OP requested a way to sleep using standard C++ which is what I provided.
 
J

Julie

Julie said:
Yes, but that isn't platform neutral and/or portable.

The OP requested a way to sleep using standard C++ which is what I provided.

That last line should read:

The OP originally requested a way to sleep using standard C++ which is what I
provided. Platform-specific solutions should be discussed in the relevant
newsgroup(s), not clc++.
 
J

John Carson

Julie said:
Julie wrote:

The OP originally requested a way to sleep using standard C++ which
is what I provided. Platform-specific solutions should be discussed
in the relevant newsgroup(s), not clc++.

Actually, he made no reference to standard C++, though perhaps you inferred
this from the newsgroup he chose to post in. I agree with your second
sentence. But I don't believe in using standard solutions that are not good
solutions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,142
Messages
2,570,818
Members
47,362
Latest member
eitamoro

Latest Threads

Top