[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: NSOperation status
From: |
David Chisnall |
Subject: |
Re: NSOperation status |
Date: |
Mon, 19 Jan 2009 23:36:20 +0000 |
On 19 Jan 2009, at 07:51, Sebastian Nowicki wrote:
In the release notes for v1.16.0 [1] it is mentioned that
NSOperation is on the to-do list. I'm wondering what the status of
that is. As far as I can tell there's no support for it whatsoever.
This is unfortunate as I would like to use this instead of NSThread
for my cross-platform framework (Cocoa & GNUstep). I'm not sure
whether to just use NSOperation and wait for it to be supported in
GNUstep or use NSThread and switch later.
If you're looking for a cross-platform wrapper around threads, you
might want to take a look at EtoileThread (part of EtoileFoundation),
which works on OS X and GNUstep and allows you to send messages
asynchronously to threads and get a future back. We use it in Mélodie
to put the decoder in a different thread - the main thread sends
messages to it periodically to information for the GUI and only blocks
when it sends messages to the objects that are returned from messages
that have not completed executing in the other thread. It also
supports calling an idle method when the message queue is empty. This
is used to (synchronously) decode the next frame and play it. It uses
an efficient lockless ring buffer when there are messages in the queue
and switches to sleeping on a condition variable when the thread is
idle. The main overhead is the cost of forwardInvocation: when the
thread is busy.
I spent a lot of time a few months ago stress testing and debugging
it, and I haven't had any bug reports since then. I wrote a bit more
about how I'm using it here:
http://etoileos.com/news/archive/2008/07/29/0231/
As always, it's BSD licensed, so feel free to do whatever you want
with it,
David