Thread: my questions on Boost

  1. #31
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Quote Originally Posted by Boost Documentation
    void wait(boost::unique_lock<boost::mutex>& lock)
    ...
    Effects:
    ... The thread will unblock when notified by a call to this->notify_one() or this->notify_all(), or spuriously.
    Quote Originally Posted by ISO/IEC 14882:2011
    30.5.1 Class condition_variable [thread.condition.condvar]
    ...
    void wait(unique_lock<mutex>& lock);
    ...
    10 Effects:
    ...
    The function will unblock when signaled by a call to notify_one() or a call to notify_all(), or spuriously.
    Quote Originally Posted by POSIX.1-2008
    An added benefit of allowing spurious wakeups is that applications are forced to code a predicate-testing-loop around the condition wait. This also makes the application tolerate superfluous condition broadcasts or signals on the same condition variable that may be coded in some other part of the application. The resulting applications are thus more robust. Therefore, POSIX.1-2008 explicitly documents that spurious wakeups may occur.
    [pthread_cond_broadcast]
    Broken. But fixed in post #29.

    gg

  2. #32
    بابلی ریکا Masterx's Avatar
    Join Date
    Nov 2007
    Location
    Somewhere nearby,Who Cares?
    Posts
    497
    ok , after some more readings and messing with classes and testing stuff in different ways and scenarios im glad to say that all my former answers to my former questions are wrong , and there are nearly easy ways to do most of the tasks and achieve what boost is seemed to not supporting it
    with my current level of knowledge on boost i revise myself :
    how can i get all threads ID issued by me in my app?
    its fairly easy , one approach can be , when issuing any threads, save their id in a vector , or save the threads in a vector, or even use an array of threads and manage them through that ( using joinable() one can say if a thread object points to a valid thread of execution or not, using this_thread__get_id() , one can get the current running thread id , and compare it if the needs be)
    how can i iterate through running threads in my app ? :
    again if one use a vector , or an array of threads object , one can easily use a for to iterate through these objects
    is there any kind of means to get all the running threads using boost library?(if it does whats the calss? if it doesnt how can i do that?)
    in this special case , boost doesnt provide any means to get all running threads in a system . host os api should be used.
    can i resume a thread after pausing it ? ( how can i pause a thread rather than using sleep? ) : using intrusion one can simulate this pausing /resuming feature , one can also use conditional variable for this purpose
    how to terminate a thread in boost ?:
    fairly easy again , one can use interrupts , or simply return when the threads needs to be terminated
    how can one check the status of a thread of execution to see e.g it was successful or not :
    one can use futures in boost::threading , and by using that query the return value of that thread

    i think these were my worst concerns when using boost . please correct me if there is sth wrong
    Last edited by Masterx; 04-17-2012 at 04:51 AM.
    Highlight Your Codes
    The Boost C++ Libraries (online Reference)

    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.."
    Bill Bryson


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. couple of questions concerning Boost::scoped_ptr
    By Masterx in forum C++ Programming
    Replies: 5
    Last Post: 04-08-2012, 08:02 PM
  2. some questions about Boost libraries
    By Masterx in forum Tech Board
    Replies: 41
    Last Post: 11-10-2010, 09:58 AM
  3. Do you use Boost?
    By sarah22 in forum C++ Programming
    Replies: 4
    Last Post: 06-04-2010, 02:15 PM
  4. boost
    By siavoshkc in forum C++ Programming
    Replies: 14
    Last Post: 08-30-2006, 10:58 PM
  5. erasing elements from a boost::ptr_vector (boost n00b)
    By Marcos in forum C++ Programming
    Replies: 2
    Last Post: 04-04-2006, 12:54 PM