First, sorry my english... Are possible define the queue size in GCD? Example: Define the max. number of task run simultaneous in a queue. -- Danilo Egêa Gondolfo Email/MSN - daniloegea@yahoo.com.br Skype - daniloegea Twitter - http://twitter.com/daniloegea Blog - http://daniloegea.wordpress.com __________________________________________________ Fale com seus amigos de graça com o novo Yahoo! Messenger http://br.messenger.yahoo.com/
Your question makes me feel like I should try to clarify my understanding of queues in libdispatch. Here goes: There's only one concurrent queue in which the "tasks" or blocks/function pointers can be run in simultaneously as far as I can tell. Every other queue is serial, and the queues themselves may run in parallel and with different priorities. This is why it makes sense to think of a queue as a context, and that you're serializing accesses to that context by enqueueing accesses and updates to that queue. The programmer's benefit in this situation is that they can isolate queue contextual data in a nice way without thinking about mutexes or semaphores etc, and the queues are really pretty inexpensive as can be seen in the game of life demo sample code in libdispatch which I think is using a queue per discrete element. Dave On Tue, Sep 28, 2010 at 1:30 PM, Danilo Egea <daniloegea@yahoo.com.br>wrote:
First, sorry my english...
Are possible define the queue size in GCD?
Example: Define the max. number of task run simultaneous in a queue.
-- Danilo Egêa Gondolfo Email/MSN - daniloegea@yahoo.com.br Skype - daniloegea Twitter - http://twitter.com/daniloegea Blog - http://daniloegea.wordpress.com
__________________________________________________ Fale com seus amigos de graça com o novo Yahoo! Messenger http://br.messenger.yahoo.com/ _______________________________________________ libdispatch-dev mailing list libdispatch-dev@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/libdispatch-dev
I think the essential answer to his question, reading between the lines, is that if you want to limit the number of concurrent operations to n, then the proper thing to do is submit them to a concurrent queue and then use a counting semaphore to implement the behavior you want (2 at a time, 3 at a time, whatever). Queues cannot have variable widths - it's either 1 or "infinite". That idea was considered but ultimately dropped given that it only made submitting things to queues even less deterministic in terms of where/how they would run, and there is already a way (again, semaphores) to get that behavior, so this would have only added complexity to all queues for little overall gain. Should someone propose a truly compelling scenario that changes the whole cost/benefit ratio, can certainly revisit the idea. - Jordan On Sep 28, 2010, at 3:37 PM, David Leimbach wrote:
Your question makes me feel like I should try to clarify my understanding of queues in libdispatch. Here goes:
There's only one concurrent queue in which the "tasks" or blocks/function pointers can be run in simultaneously as far as I can tell. Every other queue is serial, and the queues themselves may run in parallel and with different priorities.
This is why it makes sense to think of a queue as a context, and that you're serializing accesses to that context by enqueueing accesses and updates to that queue. The programmer's benefit in this situation is that they can isolate queue contextual data in a nice way without thinking about mutexes or semaphores etc, and the queues are really pretty inexpensive as can be seen in the game of life demo sample code in libdispatch which I think is using a queue per discrete element.
Dave
On Tue, Sep 28, 2010 at 1:30 PM, Danilo Egea <daniloegea@yahoo.com.br> wrote: First, sorry my english...
Are possible define the queue size in GCD?
Example: Define the max. number of task run simultaneous in a queue.
-- Danilo Egêa Gondolfo Email/MSN - daniloegea@yahoo.com.br Skype - daniloegea Twitter - http://twitter.com/daniloegea Blog - http://daniloegea.wordpress.com
__________________________________________________ Fale com seus amigos de graça com o novo Yahoo! Messenger http://br.messenger.yahoo.com/ _______________________________________________ libdispatch-dev mailing list libdispatch-dev@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/libdispatch-dev
_______________________________________________ libdispatch-dev mailing list libdispatch-dev@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/libdispatch-dev
On Sep 28, 2010, at 6:37 PM, David Leimbach wrote:
There's only one concurrent queue in which the "tasks" or blocks/function pointers can be run in simultaneously as far as I can tell. Every other queue is serial, and the queues themselves may run in parallel and with different priorities.
Minor nitpick: there are three concurrent queues: the normal one, plus one for low priority tasks and one for high-priority tasks. All the rest are serial, as you say. Mike
On 09/29/10 01:32, Michael Ash wrote:
On Sep 28, 2010, at 6:37 PM, David Leimbach wrote:
There's only one concurrent queue in which the "tasks" or blocks/function pointers can be run in simultaneously as far as I can tell. Every other queue is serial, and the queues themselves may run in parallel and with different priorities.
Minor nitpick: there are three concurrent queues: the normal one, plus one for low priority tasks and one for high-priority tasks. All the rest are serial, as you say.
Mike _______________________________________________ libdispatch-dev mailing list libdispatch-dev@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/libdispatch-dev
Ok, thank you all for the explanations!!! :) -- Danilo Egêa Gondolfo Email/MSN - daniloegea@yahoo.com.br Skype - daniloegea Twitter - http://twitter.com/daniloegea Blog - http://daniloegea.wordpress.com __________________________________________________ Fale com seus amigos de graça com o novo Yahoo! Messenger http://br.messenger.yahoo.com/
On Tue, Sep 28, 2010 at 9:32 PM, Michael Ash <michael.ash@gmail.com> wrote:
On Sep 28, 2010, at 6:37 PM, David Leimbach wrote:
There's only one concurrent queue in which the "tasks" or blocks/function pointers can be run in simultaneously as far as I can tell. Every other queue is serial, and the queues themselves may run in parallel and with different priorities.
Minor nitpick: there are three concurrent queues: the normal one, plus one for low priority tasks and one for high-priority tasks. All the rest are serial, as you say.
Mike
Actually I'm glad you said that, because I'd not touched this stuff in a bit. Thanks Mike! Dave
_______________________________________________ libdispatch-dev mailing list libdispatch-dev@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/libdispatch-dev
participants (4)
-
Danilo Egea
-
David Leimbach
-
Jordan K. Hubbard
-
Michael Ash