Re: CALayer -drawInContext and GCD
Re: CALayer -drawInContext and GCD
- Subject: Re: CALayer -drawInContext and GCD
- From: David Duncan <email@hidden>
- Date: Thu, 2 Sep 2010 09:44:11 -0700
On Sep 2, 2010, at 9:40 AM, Chris Parker wrote:
> On 2 Sep 2010, at 8:52 AM, David Duncan wrote:
>
>> On Sep 2, 2010, at 7:39 AM, Vincent Habchi wrote:
>>
>>> I just wanted to know someone has already tried to successfully send a CALayer -drawInContext method to a GCD dispatch queue. I suspect this is not possible, because of main loop related issue, but this is unclear.
>>
>> This can be done, but you have to ensure that your layer's drawing is threadsafe. Should be as simple as this with that precondition met:
>>
>> dispatch_async(queue, ^{
>> [layer display];
>> [CATransaction flush];
>> }
>
> There is (almost) never any reason for anyone to be calling +[CATransaction flush] directly. You'll cause all sorts of unexpected things to happen w.r.t. extant CATransactions. You should let +flush be called at the end of the run loop on its own.
The work is occurring on a GCD queue, which has no runloop running, as such it won't be called on its own and there are no other extant transactions to be affected. Assuming 'queue' isn't the main thread queue that is.
--
David Duncan
_______________________________________________
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