On 11 Jan 2007, at 11:18, David Chisnall wrote:
On 11 Jan 2007, at 10:47, Quentin Mathé wrote:
This is surely safer. Though providing something like [[myObject inNewThread] doSomething] as MPWFoundation does could be useful for "normal" object.

Actually, I forgot to mention, I did implement an - invokeInNewThread: method in the category on NSObject. If you manually construct an NSInvocation, you can have it complete in a new thread. The down side is that it's not transparent, however it would be quite easy to add a -inNewThread method that returned (yet another) proxy object that implements the -forwardInvocation: method to this method.

Actually, I am an idiot. ETThreadedObject has an - initWithObject: method, so this should work for the -inNewThread method:

- (id) inNewThread
{
        return [[[ETThreadedObject alloc] initWithObject:self] autorelease];
}

I might replace the -invokeInNewThread: method with this, since it's a lot simpler and therefore probably contains fewer bugs.

Of course, the same caveat applies; don't send any synchronous messages to your object until the asynchronous one has completed, or things will go wrong...
_______________________________________________
Etoile-dev mailing list
[email protected]
https://mail.gna.org/listinfo/etoile-dev

Reply via email to