[interfacekit] Re: deadlock with BApplication/BWindow

Ingo Weinhold wrote:
On 2005-03-12 at 17:50:35 [+0100], Adi Oanca wrote:

Have a poroblem when quiting be_app. I have a solution for it but I want your opinion on it.

The problem:
------------------------------------------

[...]

oups, deadlock! :-)

Here's my solution:

[...]

That's it. Comments, other ideas?


In your solution you lock a window with the looper list lock being held. That window could just be handling a message, which might involve posting a message to another looper, which in turn would try to acquire the looper list lock. Deadlock.

Hmmm... this gives me an idea... Look looper list, get looper list and then unlock. Then call looperList.ItemAt(i)->Lock() and if that succeeds, then looper is still valid. I was afraid calling ::Lock() on a already deleted window would get me in the debugger with a segmentation fault; apparently my problem with gLooperList in _Lock() is quite beneficial. :-)

        That doesn't solve the creation for new windows, but that's not a 
problem, I'll
seek a way to prevent that; that wasn't my objective, but the above one.

        What do you think?


Thanks, Adi.

Other related posts: