Solved

boost::thread::sleep() question

Posted on 2012-04-05
4
596 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

821 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