Re: NSWorkspace race condition
Re: NSWorkspace race condition
- Subject: Re: NSWorkspace race condition
- From: Deirdre Saoirse Moen <email@hidden>
- Date: Wed, 16 May 2001 23:36:39 -0700
I have stumbled upon a race condition that causes my app to hang.
Is there something I'm doing wrong, or is this a bug in Cocoa?
It's very simple to reproduce: My app is set to be notified when a
disk mounts with "NSWorkspaceDidMountNotification", When I insert a
CDROM or Zip disk, the notification happens, and I call code to
update my internal representation of all mounted volumes. This code
eventually calls...
From what you've described it's not a race condition, which is when
the result is not deterministic but depends upon which thread wins
the race. You're describing something that always has the same result.
Sounds more like you're creating a deadlock.
Rather than try and update the representation there, flag that it
needs to be updated and do the update later.
This might not be as simple for you, but it does eliminate the
problem and is the general solution for a deadlock.
--
_Deirdre Stash-o-Matic:
http://weirdre.com http://deirdre.net
Macintosh Developer (seeking work): Will work for Cocoa
"I love deadlines. I like the whooshing sound they make as they fly by."
- Douglas Adams