Re: Cheating a synchronous call on the main thread
Re: Cheating a synchronous call on the main thread
- Subject: Re: Cheating a synchronous call on the main thread
- From: Jens Alfke <email@hidden>
- Date: Mon, 29 Jun 2015 09:33:34 -0700
> On Jun 29, 2015, at 9:14 AM, Gavin Eadie <email@hidden> wrote:
>
> Can anyone, with more knowledge than we have, suggest a trick that allows an apparently synchronous call on the main thread without impacting performance?
Not without some nasty hacks that I wouldn’t recommend.
The simplest one is to run a nested runloop while you wait for the async call to complete. This will allow the app to keep handling user events. The problem is that your code can now be called re-entrantly and you can run into some really confusing problems that way (it’s happened to me.)
Other solutions involve crazy runtime manipulation of the stack to accomplish what functional languages call “continuations”. This is sort-of kind-of doable in C, and I’ve looked into it, but the complexity isn’t worth it.
—Jens
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden