Solved

boost::thread::sleep() question

Posted on 2012-04-05
4
591 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
  • 2
4 Comments
 
LVL 31

Accepted Solution

by:
Zoppo earned 100 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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

810 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