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
#include
#include
#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
Thanks!
Michael