title: gcd: control number of parallel tasks
body: <p>Using grand central dispatch, is there a way to control the number of tasks that run concurrently? Meaning, I want to use dispatch_async, call it, say, 100 times, but only have at most, say, 4 tasks running concurrently. If two of the four tasks were to finish simultaneously, then two more should start immediately. I've seen a suggestion to use a barrier dispatch after dispatching 4 tasks, but that will require all 4 tasks to finish, then the barrier, then more tasks - not what I want.</p>