|
Boost Users : |
Subject: Re: [Boost-users] Interrupting interprocess::message_queue::receive
From: Aaron_Wright_at_[hidden]
Date: 2012-04-13 13:40:47
I was caught by this same thing a while ago. I was told that interrupting
interprocess waits is not trivial and is not implemented. I just had to
switch to a timed wait and sort of poll for the interrupt.
--- Aaron Wright From: Michael Herrmann <mherrmann.at_at_[hidden]> To: boost-users_at_[hidden] Date: 04/12/2012 03:51 AM Subject: [Boost-users] Interrupting interprocess::message_queue::receive Sent by: boost-users-bounces_at_[hidden] Hi all, I am receiving messages from a message_queue via the blocking receive(...)-method from a separate boost::thread. When I interrupt this thread, the receive(...)-method never returns (not even with an thread::thread_interrupted exception). Am i doing something wrong or could this be a bug in message_queue? The situation I am talking about is illustrated by the following program never returning: #include <boost/thread.hpp> #include <boost/interprocess/detail/config_begin.hpp> #include <boost/interprocess/ipc/message_queue.hpp> #include <iostream> #include <vector> using namespace boost::interprocess; void receive() { try { message_queue mq(open_or_create, "message_queue", 100, sizeof(int)); unsigned int priority; message_queue::size_type recvd_size; int number; std::cout << "Trying to receive one int..." << std::endl; mq.receive(&number, sizeof(number), recvd_size, priority); } catch(interprocess_exception &ex) { message_queue::remove("message_queue"); std::cout << "Exception occurred: " << ex.what() << std::endl; } catch(boost::thread_interrupted &ex) { std::cout << "Thread interrupted. " << std::endl; } } int main() { message_queue::remove("message_queue"); boost::thread t(receive); t.interrupt(); t.join(); } #include <boost/interprocess/detail/config_end.hpp> Thanks! Michael _______________________________________________ Boost-users mailing list Boost-users_at_[hidden] http://lists.boost.org/mailman/listinfo.cgi/boost-users
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