Skip to content
aleclarson edited this page Oct 21, 2014 · 1 revision

A Group watches two or more concurrent tasks.

If all tasks complete, the closure you pass to done() is called.

If any task fails to complete in x seconds, the closure you pass to wait() is called.

let group = Group(1)

gcd.async {

  // do some work...
  
  --group
}

if someCondition {
  
  ++group
  
  gcd.async {
    
    // do some other work...
    
    --group
  }
}

group.done {
	
  // do something when both are finished...
}

group.wait(1) {
  
  // do something if the group isn't done in 1 second...
}
Clone this wiki locally