Solved

boost::thread::sleep() question

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

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 30

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
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 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.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now