?
Solved

boost::thread::sleep() question

Posted on 2012-04-05
4
Medium Priority
?
606 Views
Last Modified: 2012-04-14
I am having a wrapper thread class that wraps boost::thread instance to create a thread.

If mThread is the boost::thread, why is that

  void Thread::sleep(long milliseconds)
    {
      mThread->sleep(boost::posix_time::milliseconds(milliseconds));
    }  

does not work. I have seen couple of examples like this onthe net. Can someone help?
0
Comment
Question by:prain
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 31

Accepted Solution

by:
Zoppo earned 400 total points
ID: 37812254
Hi prain,

the sleep function is not a member function of the thread and it's not intended to be used to give one thread the possibility to let another one sleep.

The only thing sleep does is let the calling thread sleep, so if you want a thread to sleep for some time you have to call sleep from within that thread's threadproc.

Hope that helps,

ZOPPO
0
 

Author Comment

by:prain
ID: 37836136
I've requested that this question be deleted for the following reason:

Did not receive the intended solution
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 37836137
Hi prain,

sorry, I understand that you don't like the answer I wrote because you hoped it's possible to let another thread sleep this way, but that doesn't mean the answer is not correct.

Sometimes the only correct answer to a question unfortunateley is "No" or "That's not possible".

Therefore I'm against deleting this question.

ZOPPO
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question