I am having problems understanding GCD. i need to use dispatch_async to spawn the function put_values() which will in an endless loop put values into a buffer. Get_values() will remove then also in an endless loop. I therefore have to run them at the same time without order to see if i implemented my semaphores for waiting correctly. WIll the code below do that (running them asynchronously
) ?
Thank you !
dispatch_queue_t producer = dispatch_queue_create("producer", NULL);
dispatch_queue_t consumer = dispatch_queue_create("consumer", NULL);
dispatch_async(producer,
^{
put_values();
});
dispatch_async(consumer,
^{
get_values();
});
dispatch_main();
Your code should do exactly that, unless I am missing something. Because you are using two different queues they should both run at the same time.