You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
dispatch_group_tdispatch_group_create();
// 같은 group 의 작업이라도 queue 가 같을 필요는 없다.voiddispatch_group_async(dispatch_group_t group,
dispatch_queue_t queue,
dispatch_block_t block);
voiddispatch_group_enter(dispatch_group_t group); // group 의 작업 수 1 증가voiddispatch_group_leave(dispatch_group_t group); // group 의 작업 수 1 감소// 현재 스레드를 block 하고 기다린다// timeout 전에 끝나면 0을, 그렇지 않으면 0이 아닌 값을 리턴// timeout 을 DISPATCH_TIME_FOREVER 로 하면 영원히 기다린다.longdispatch_group_wait(dispatch_group_t group,
dispatch-time_t timeout);
// 현재 스레드를 block 하지 않는다. // group이 끝나면 queue에서 block을 실행한다.voiddispatch_group_notify(dispatch_group_t group,
dispatch_queue_t queue,
dispatch_block_t block);
하지만 여러 개의 작업이 있다고 해서 매번 디스패치 그룹을 쓸 필요는 없다.
모든 작업이 하나의 serial queue 에서 이루어진다면 굳이 group을 쓸 필요가 없다.