Code: Select all
wxMessageQueueError Post(const Message& msg)
{
wxMutexLocker locker(m_mutex);
wxCHECK( locker.IsOk(), wxMSGQUEUE_MISC_ERROR );
m_messages.push(msg);
m_conditionNotEmpty.Signal();
return wxMSGQUEUE_NO_ERROR;
}
Code: Select all
wxMessageQueueError Post(const Message& msg)
{
wxMutexLocker locker(m_mutex);
wxCHECK( locker.IsOk(), wxMSGQUEUE_MISC_ERROR );
m_messages.push(msg);
m_conditionNotEmpty.Signal();
return wxMSGQUEUE_NO_ERROR;
}
No, that would make the class pretty useless. What makes you think so?When multiple thread Post simultaniously, some may fail instead of blocking while the queue is busy, is it right?
doublemax wrote:No, that would make the class pretty useless. What makes you think so?
Code: Select all
wxMutex m;
wxMutexLocker locker1(m);
bool ok1 = locker1.IsOk();
wxMutexLocker locker2(m);
bool ok2 = locker2.IsOk();
Note that if this mutex is already locked by the caller thread, this function doesn't block but rather immediately returns.
Right, blocks in difference threads. Difference behaviors in differenct situations, this is a little complex.doublemax wrote:That's not a valid test as both locks are done in the same thread.
Code: Select all
if (deadlock is detected)
{
// no efficient procedure here, instead re-coding is needed
}
I can't think of a scenario where using wxMessageQueue() can create a deadlock. Not even if i tried to create one on purpose.Right, blocks in difference threads. Difference behaviors in differenct situations, this is a little complex.