Boost logo

Boost Users :

From: Darryl Green (Darryl.Green_at_[hidden])
Date: 2006-10-11 02:48:15


 
Hi Daniel,
boost::thread:sleep takes a time, not a duration. For details, rationale
etc rtfm.

________________________________

        From: boost-users-bounces_at_[hidden]
[mailto:boost-users-bounces_at_[hidden]] On Behalf Of Daniel Winsor
        Sent: Wednesday, 11 October 2006 4:40 PM
        To: boost-users_at_[hidden]
        Subject: [Boost-users] [thread] bug: thread::sleep can't 'Idle'
        
        
        
        #include
        <boost/thread/thread.hpp>
        #include <boost/thread/xtime.hpp>
        #include <Windows.h>//for sleep
        
        void
        ExecuteThread()
        {
        for(;;) {
        boost::xtime time;
        time.nsec = 0;
        time.sec = 1;
        boost::thread::sleep(time);
        //Sleep(1000);
        }
        }
        
        int
        main()
        {
        boost::thread thread1(ExecuteThread);
        boost::thread thread2(ExecuteThread);
        thread1.join();
        thread2.join();
        return 0;
        }
         
        When this program is run with Sleep() instead of
boost::thread::sleep(), and there are no other cpu intensive programs
running, Task Manager shows 99% of the cpu (dual core) is idle.
However, when it is run with boost::thread::sleep(), 99% of the cpu is
being used by the program! This is a problem because powersaving
features no longer work.
         
        When this program with boost::thread::sleep() is run with
another program that is cpu intensive, Task Manager reports the other
program uses 99% of the cpu, so there is no problem there.
         
        I am using an overclocked Intel Core 2 Duo 6400 if that matters.

##########################################################################
This e-mail is for the use of the intended recipient(s) only. If you have
received this e-mail in error, please notify the sender immediately and
then delete it. If you are not the intended recipient, you must not use,
disclose or distribute this e-mail without the author's prior permission.
We have taken precautions to minimise the risk of transmitting software
viruses, but we advise you to carry out your own virus checks on any
attachment to this message. We cannot accept liability for any loss or
damage caused by software viruses.

##########################################################################



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net