Cocoa thread-safety
Cocoa thread-safety
- Subject: Cocoa thread-safety
- From: Steve Klingsporn <email@hidden>
- Date: Fri, 25 Oct 2002 22:52:41 -0500
It's 2002. Any idea if and when the AppKit will be thread-safe?
Just curious. A lot of people bashed BeOS for being "incomplete"
and all, but threading issues and asynchronicity is one thing they
got right. There were some gotchas, but nothing like some of the
problems I've experienced with Cocoa.
I'm looking for an elegant way for a thread to notify my main thread
that something needs to happen. I've read everything I can get
a hold of via cocoa.mamasam.com. Here's what I've discovered,
or read:
- I can have an NSTimer attached to my main NSRunLoop that
fires every .25 seconds or so, but my app eats up a consistent
4% of the CPU. This doesn't seem acceptable to me to do scrolling
in an NSTextView that could change as a result of an incoming or
outgoing chat message.
- NSNotifications are served by the thread they are posted with. No
luck.
- NSDistributedNotificationCenter has a 5 or so notification deep limit
and then it stops dropping notifications.
I noticed that in Jaguar, there are methods for invoking something in
the
main thread -- from Objective-C. My app is 100% Java. I suppose I
could
do something like wrap this using an Objective-C stub, but I'd like to
keep
everything in Java, and likewise do everything in Objective-C for my
Objective-C projects.
When I update the NSTextStorage object associated with my NSTextView
from another thread, everything is cool. When I scroll the view from
that same
background thread, everything is cool. When I switch the NSTabView that
the NSTextView lives in from the main thread while the background thread
is updating the view, my main thread locks up and the background thread
keeps doing its thing. This is not cool.
It seems that having threads that are associated with network
connections
doing things to a UI is a pretty common problem.
I hope Apple is not so locked into compatibility madness (as they were
in the
last 15 years with the old platform and still are in the new platform)
that they
cannot fix the AppKit and make it thread-safe. It should be.
Thanks. I feel a little bit better now after venting.
Steve
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.