Yep.
To state first what a deadlock if ever needed :[quote]A system where multiple threads coexist in the same address space is extremely vulnerable to data corruption and deadlock. While there is a trade-off between these two problems, deadlock remains the ultimate bug and is almost impossible to eradicate.
This article will discuss a technique for detecting and breaking deadlocks in a multithreaded environment. It will also present a simple and powerful way to analyze why the deadlock occurred.
A deadlock is a situation where each thread in a set of at least two threads is waiting for a resource (shared data is also considered a resource), which is locked by another thread in the set. The result is that each thread in the set is waiting indefinitely for the resources to be released. [/quote]
Then here is the simple diagram of my app :
The engine thread updates - many times during a user session - the GUI, with 3 callbacks (static functions):
//In the concerned class
S_SequencerPrincipal_address = this;
m_engines-> addCrossAControlPointAction (& controlPointHasBeenDone);
m_engines-> addWaitedTriggerPointMessageAction (& waitedTriggerPointCallBack);
m_engines-> addIsExecutionFinishedAction (& isExecutionFinished);
Each callback calls main object of JuceAPP by the given address.
Finally here are my source functions troubling :
static Sequencer* s_SequencerPrincipal_address = NULL;
/* if component methods are being called from threads other than the message
thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe.
line 1641 checkMessageManagerIsLocked
line 341 pas de thread current*/
static void controlPointHasBeenDone(unsigned int boxId, unsigned int controlPointIndex){
if(s_SequencerPrincipal_address==NULL) return;
const MessageManagerLock mmLock()) ;
s_SequencerPrincipal_address->getLedOut()->setVisible(true);
jassert(controlPointIndex > 0);
jassert(s_SequencerPrincipal_address->getBox(boxId) > 0);
s_SequencerPrincipal_address->getBox(boxId)->controlPointHasBeenDone(controlPointIndex);
switch (controlPointIndex) {
case 1:
s_SequencerPrincipal_address->showComments(boxId);
break;
default:
s_SequencerPrincipal_address->removeComment(boxId);
break;
}
s_SequencerPrincipal_address->getLedOut()->fadeOutComponent(50,0,0,0);
s_SequencerPrincipal_address->repaint();
};
static void waitedTriggerPointCallBack(bool isWaited, unsigned int triggerId, unsigned int boxId, unsigned int controlPointIndex, std::string triggerMessage){
if(s_SequencerPrincipal_address==NULL) return;
const MessageManagerLock mmLock();
s_SequencerPrincipal_address->getLedIn()->setVisible(true);
s_SequencerPrincipal_address->getTrigger(triggerId)->waitedTriggerPointCallBack(isWaited);
if(isWaited){
s_SequencerPrincipal_address->appendTriggeredBoxComment("[o] " + s_SequencerPrincipal_address->getBox(boxId)->getTitle() + ": " + s_SequencerPrincipal_address->getBox(boxId)->getComment());
}
else {
s_SequencerPrincipal_address->removeComment (boxId);
}
s_SequencerPrincipal_address->getLedOut()->fadeOutComponent(50, 0,0,0);
s_SequencerPrincipal_address->repaint();
};
static void isExecutionFinished() {
if(s_SequencerPrincipal_address==NULL) return;
const MessageManagerLock mmLockNess;
s_SequencerPrincipal_address->getController()->stop();
s_SequencerPrincipal_address->repaint();
};
Download file here: http://27sens.com/deadlockingfil.zip
And finally, the god stack:
semaphore_wait_signal_trap
pthread_mutex_lock
juce::CriticalSection::enter
juce::MessageManagerLock::MessageManagerLock
juce::MessageManager::deliverMessage
EventHandlerProc
...
More info by there for any has time on it: http://27sens.com/deadlock.pdf
Thank you for any help you’ll take time to give.
AsR