UI thread callbacks question
UI thread callbacks question
- Subject: UI thread callbacks question
- From: Cryx <email@hidden>
- Date: Sun, 21 Apr 2002 22:25:42 -0500
I've written an application that embeds a perl interpreter. An obj-c
object posts an event into a perl event loop running in another thread,
and the the event finishes via an XS callback (essentially perl in C
glue). The callback knows nothing of the originating obj-c, so the XS
callback posts a notification, which is picked up by the object that
spawned the interpreter. This selector calls the main thread via a DO
connection.
This seemingly works well, but I can't help but feel it's overkill.
Other methods I employed were casting the calling obj-c object into a
void ptr and passing that to perl, and having perl pass it back via XS,
then using that ptr to dispatch into the calling object -- it worked,
but it felt really really dirty. Plus it deadlocked the app under load,
read on.
The DO connection only came into play after I seemingly learned that
scroll/text views really aren't thread safe at all, no matter what the
documentation says about lockFocus. Even after ensuring that the main
thread and the perl-running thread used lockFocus and/or a recursive
lock to update the scroll view, the application would deadlock under
load testing. Thread viewer shows that the main thread (which is trying
to update the entire display) and the subthread (which is trying to
draw) are blocking on a common mutex in the bowels of the view machinery.
So much for the world's most advanced OS, but I'll work around it. I
won't gripe about how spawning an embedded perl interpreter with an
overinflated & invalid argv count can corrupt the process table and then
then crash the entire machine (UI freezes and inbound telnets hang). No
user level gaffe should tank the OS...
So is there a better way to issue callbacks? What I have implemented
works well, but it just doesn't feel right. Any implementation advice
would be appreciated.
_______________________________________________
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.