Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSWorkspace race condition



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


References: 
 >NSWorkspace race condition (From: Steve Gehrman <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.