
8 Sep
2009
8 Sep
'09
2:20 a.m.
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