[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: none

From: David Chisnall
Subject: Re: none
Date: Mon, 15 Jun 2015 19:01:15 +0100

On 15 Jun 2015, at 16:14, allynm <mark.allyn@verizon.net> wrote:
> OK, the immediate answer to my question is that dispatch_async runs in the
> background and additional code needs to be added to inform the main thread
> of the results of the calc.  If I change dispatch_async to dispatch_sync the
> code executes properly.

Changing it to dispatch_sync rather misses the point of using libdispatch (i.e. 
you get no parallelism).  The correct solution is to add some synchronisation.  
For a concurrent queue, this would probably be adding a barrier to the queue 
and then a block that released a semaphore and then releasing a semaphore (I 
thought that there was a convenience API for this, but I can’t find it).

> If anyone would care to educate me better on GCD or knows a good tutorial
> (other than MAC devs stuff) I'd be grateful.

Apple produces three docs (not linked, because they are not so good at 
producing stable URLs):

Introducing Blocks and Grand Central Dispatch
Concurrency Programming Guide
Grand Central Dispatch (GCD) Reference

These (in this order) are what I would recommend to someone wanting to play 
with libdispatch / ObjC.


-- Sent from my brain

reply via email to

[Prev in Thread] Current Thread [Next in Thread]