I have several methods for which I'd like to provide asynchronous and synchronous variants. These methods are not simple operations and have non-void return values. Is there a good model to follow in implementing this? I don't recall ever seeing a technique for this in any of the Cocoa documentation I've looked at.
In my mind I've got two options: 1. The synchronous version (fooSynch) is either the implementation or calls private implementation (_foo) on the same thread. The asynchronous version would detach a new thread to some method (threadedFood) that runs fooSynch and then takes care of calling callbacks, informing a delegate, etc. 2. The asynchronous version detaches a new thread to the implementation (_foo) that contains the operation and any necessary calls to callbacks, delegates, etc. The synchronous version wraps a call to the asynchronous version and somehow blocks the thread from returning until the asynchronous call completes. I'm not sure how to do this. I imagine it may involve installing ports in the run loop (over which the thread could communicate) and then running the run loop until the thread signals completion. That sounds a little too contrived. I'm curious how people tackle this problem pre-Leopard and performSelector:onThread:withObject:waitUntilDone: API Thanks, -Andy _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]