
I have the following code and it terminates as expected. When I call the destructor it interrupts the thread.
But if I change the this_thread::sleep to this_thread::yield the join() never happens and the program hangs.
I must be misunderstanding yield. But I really don't want a sleep if possible.
Thanks,
John
MessageQueueHandler::~MessageQueueHandler()
{
// Terminate the thread
pMessageQueueInputThread->interrupt();
pMessageQueueInputThread->join();
delete pMessageQueueInputThread;
}
void MessageQueueHandler::MessageQueueInputThread()
{
unsigned int receivedSize;
unsigned int priority;
char buffer[queueMaximumMessageSize];
boost::this_thread::interruption_enabled();
try
{
while(1)
{
// Process all messages in the queue
while(inputMessageQueue->try_receive(buffer, queueMaximumMessageSize, receivedSize, priority))
{
BaseMessage * msg = reinterpret_cast