Subject: [boost] [interprocess]why message_queue receive() will consume so much CPU resource
From: jon_zhou_at_[hidden]
Date: 2009-09-07 22:20:32


Hi there

I just found that message_queue::receive() or message_queue:: timed_receive () consume high CPU
resource, (99% CPU) the code like the below:

//create message_queue

date d(2009,Sep,8); //an arbitrary date
//construct a time by adding up some durations durations
ptime t1(d, hours(0)+minutes(0)+seconds(1)+millisec(0));

while (1)
{
  for(int i = 0; i < 100; ++i){
    int number;
    //mq.receive(&number, sizeof(number), recvd_size, priority);
    mq.timed_receive(&number, sizeof(number), recvd_size, priority,t1);
  }
}

As I know, both the receive() & timed_receive() are block method, there should be sleep mechanism inside. why it still need so much CPU resource?

Thanks
jon