Skip to content

Instantly share code, notes, and snippets.

@ankitthakur
Last active August 29, 2015 14:23
Show Gist options
  • Save ankitthakur/dd945a66924fbd697169 to your computer and use it in GitHub Desktop.
Save ankitthakur/dd945a66924fbd697169 to your computer and use it in GitHub Desktop.
//
// GCDUtils.h
// GCD
//
// Created by Ankit Thakur on 6/23/15.
// Copyright (c) 2015 GCD. All rights reserved.
//
#import <Foundation/Foundation.h>
dispatch_queue_t GlobalMainQueue();
dispatch_queue_t GlobalUserInteractiveQueue(void);
dispatch_queue_t GlobalUserInitiatedQueue(void);
dispatch_queue_t GlobalUtilityQueue(void);
dispatch_queue_t GlobalBackgroundQueue(void);
@interface GCDUtils : NSObject
@end
//
// GCDUtils.m
// GCD
//
// Created by Ankit Thakur on 6/23/15.
// Copyright (c) 2015 GCD. All rights reserved.
//
#import "GCDUtils.h"
dispatch_queue_t GlobalMainQueue() {
return dispatch_get_main_queue();
}
dispatch_queue_t GlobalUserInteractiveQueue(void) {
return dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, 0);
}
dispatch_queue_t GlobalUserInitiatedQueue(void) {
return dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0);
}
dispatch_queue_t GlobalUtilityQueue(void) {
return dispatch_get_global_queue(QOS_CLASS_UTILITY, 0);
}
dispatch_queue_t GlobalBackgroundQueue(void) {
return dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0);
}
@implementation GCDUtils
@end
2015-06-23 16:08:05.496 GCD[6663:357153] maxIndex: 15 -> queueName :GlobalBackgroundQueue
2015-06-23 16:08:05.496 GCD[6663:357153] print queueName: GlobalBackgroundQueue index 0 for i = 0
2015-06-23 16:08:05.496 GCD[6663:357203] maxIndex: 15 -> queueName :GlobalBackgroundQueue
2015-06-23 16:08:05.496 GCD[6663:357202] maxIndex: 18 -> queueName :GlobalBackgroundQueue
2015-06-23 16:08:05.496 GCD[6663:357153] print queueName: GlobalBackgroundQueue index 1 for i = 0
2015-06-23 16:08:05.496 GCD[6663:357203] print queueName: GlobalBackgroundQueue index 0 for i = 1
2015-06-23 16:08:05.496 GCD[6663:357153] print queueName: GlobalBackgroundQueue index 2 for i = 0
2015-06-23 16:08:05.496 GCD[6663:357202] print queueName: GlobalBackgroundQueue index 0 for i = 2
2015-06-23 16:08:05.496 GCD[6663:357153] print queueName: GlobalBackgroundQueue index 3 for i = 0
2015-06-23 16:08:05.497 GCD[6663:357203] print queueName: GlobalBackgroundQueue index 1 for i = 1
2015-06-23 16:08:05.497 GCD[6663:357153] print queueName: GlobalBackgroundQueue index 4 for i = 0
2015-06-23 16:08:05.497 GCD[6663:357202] print queueName: GlobalBackgroundQueue index 1 for i = 2
2015-06-23 16:08:05.497 GCD[6663:357153] print queueName: GlobalBackgroundQueue index 5 for i = 0
2015-06-23 16:08:05.497 GCD[6663:357203] print queueName: GlobalBackgroundQueue index 2 for i = 1
2015-06-23 16:08:05.530 GCD[6663:357153] print queueName: GlobalBackgroundQueue index 6 for i = 0
2015-06-23 16:08:05.530 GCD[6663:357202] print queueName: GlobalBackgroundQueue index 2 for i = 2
2015-06-23 16:08:05.530 GCD[6663:357153] print queueName: GlobalBackgroundQueue index 7 for i = 0
2015-06-23 16:08:05.530 GCD[6663:357153] print queueName: GlobalBackgroundQueue index 8 for i = 0
2015-06-23 16:08:05.530 GCD[6663:357203] print queueName: GlobalBackgroundQueue index 3 for i = 1
2015-06-23 16:08:05.530 GCD[6663:357153] print queueName: GlobalBackgroundQueue index 9 for i = 0
2015-06-23 16:08:05.530 GCD[6663:357153] print queueName: GlobalBackgroundQueue index 10 for i = 0
2015-06-23 16:08:05.530 GCD[6663:357153] print queueName: GlobalBackgroundQueue index 11 for i = 0
2015-06-23 16:08:05.530 GCD[6663:357203] print queueName: GlobalBackgroundQueue index 4 for i = 1
2015-06-23 16:08:05.531 GCD[6663:357153] print queueName: GlobalBackgroundQueue index 12 for i = 0
2015-06-23 16:08:05.530 GCD[6663:357202] print queueName: GlobalBackgroundQueue index 3 for i = 2
2015-06-23 16:08:05.586 GCD[6663:357203] print queueName: GlobalBackgroundQueue index 5 for i = 1
2015-06-23 16:08:05.586 GCD[6663:357153] print queueName: GlobalBackgroundQueue index 13 for i = 0
2015-06-23 16:08:05.586 GCD[6663:357202] print queueName: GlobalBackgroundQueue index 4 for i = 2
2015-06-23 16:08:05.586 GCD[6663:357153] print queueName: GlobalBackgroundQueue index 14 for i = 0
2015-06-23 16:08:05.586 GCD[6663:357202] print queueName: GlobalBackgroundQueue index 5 for i = 2
2015-06-23 16:08:05.586 GCD[6663:357203] print queueName: GlobalBackgroundQueue index 6 for i = 1
2015-06-23 16:08:05.587 GCD[6663:357202] print queueName: GlobalBackgroundQueue index 6 for i = 2
2015-06-23 16:08:05.587 GCD[6663:357203] print queueName: GlobalBackgroundQueue index 7 for i = 1
2015-06-23 16:08:05.587 GCD[6663:357202] print queueName: GlobalBackgroundQueue index 7 for i = 2
2015-06-23 16:08:05.592 GCD[6663:357202] print queueName: GlobalBackgroundQueue index 8 for i = 2
2015-06-23 16:08:05.592 GCD[6663:357203] print queueName: GlobalBackgroundQueue index 8 for i = 1
2015-06-23 16:08:05.592 GCD[6663:357202] print queueName: GlobalBackgroundQueue index 9 for i = 2
2015-06-23 16:08:05.592 GCD[6663:357203] print queueName: GlobalBackgroundQueue index 9 for i = 1
2015-06-23 16:08:05.593 GCD[6663:357202] print queueName: GlobalBackgroundQueue index 10 for i = 2
2015-06-23 16:08:05.593 GCD[6663:357203] print queueName: GlobalBackgroundQueue index 10 for i = 1
2015-06-23 16:08:05.593 GCD[6663:357202] print queueName: GlobalBackgroundQueue index 11 for i = 2
2015-06-23 16:08:05.593 GCD[6663:357203] print queueName: GlobalBackgroundQueue index 11 for i = 1
2015-06-23 16:08:05.593 GCD[6663:357202] print queueName: GlobalBackgroundQueue index 12 for i = 2
2015-06-23 16:08:05.593 GCD[6663:357203] print queueName: GlobalBackgroundQueue index 12 for i = 1
2015-06-23 16:08:05.593 GCD[6663:357202] print queueName: GlobalBackgroundQueue index 13 for i = 2
2015-06-23 16:08:05.594 GCD[6663:357203] print queueName: GlobalBackgroundQueue index 13 for i = 1
2015-06-23 16:08:05.594 GCD[6663:357203] print queueName: GlobalBackgroundQueue index 14 for i = 1
2015-06-23 16:08:05.594 GCD[6663:357202] print queueName: GlobalBackgroundQueue index 14 for i = 2
2015-06-23 16:08:05.594 GCD[6663:357153] maxIndex: 29 -> queueName :GlobalUserInitiatedQueue
2015-06-23 16:08:05.594 GCD[6663:357202] maxIndex: 29 -> queueName :GlobalUserInitiatedQueue
2015-06-23 16:08:05.594 GCD[6663:357203] maxIndex: 23 -> queueName :GlobalUserInitiatedQueue
2015-06-23 16:08:05.594 GCD[6663:357153] print queueName: GlobalUserInitiatedQueue index 0 for i = 0
2015-06-23 16:08:05.594 GCD[6663:357202] print queueName: GlobalUserInitiatedQueue index 0 for i = 1
2015-06-23 16:08:05.594 GCD[6663:357203] print queueName: GlobalUserInitiatedQueue index 0 for i = 2
2015-06-23 16:08:05.594 GCD[6663:357153] print queueName: GlobalUserInitiatedQueue index 1 for i = 0
2015-06-23 16:08:05.594 GCD[6663:357202] print queueName: GlobalUserInitiatedQueue index 1 for i = 1
2015-06-23 16:08:05.594 GCD[6663:357203] print queueName: GlobalUserInitiatedQueue index 1 for i = 2
2015-06-23 16:08:05.594 GCD[6663:357153] print queueName: GlobalUserInitiatedQueue index 2 for i = 0
2015-06-23 16:08:05.595 GCD[6663:357202] print queueName: GlobalUserInitiatedQueue index 2 for i = 1
2015-06-23 16:08:05.595 GCD[6663:357203] print queueName: GlobalUserInitiatedQueue index 2 for i = 2
2015-06-23 16:08:05.595 GCD[6663:357153] print queueName: GlobalUserInitiatedQueue index 3 for i = 0
2015-06-23 16:08:05.595 GCD[6663:357203] print queueName: GlobalUserInitiatedQueue index 3 for i = 2
2015-06-23 16:08:05.595 GCD[6663:357202] print queueName: GlobalUserInitiatedQueue index 3 for i = 1
2015-06-23 16:08:05.595 GCD[6663:357153] print queueName: GlobalUserInitiatedQueue index 4 for i = 0
2015-06-23 16:08:05.595 GCD[6663:357203] print queueName: GlobalUserInitiatedQueue index 4 for i = 2
2015-06-23 16:08:05.595 GCD[6663:357202] print queueName: GlobalUserInitiatedQueue index 4 for i = 1
2015-06-23 16:08:05.595 GCD[6663:357153] print queueName: GlobalUserInitiatedQueue index 5 for i = 0
2015-06-23 16:08:05.595 GCD[6663:357203] print queueName: GlobalUserInitiatedQueue index 5 for i = 2
2015-06-23 16:08:05.597 GCD[6663:357153] print queueName: GlobalUserInitiatedQueue index 6 for i = 0
2015-06-23 16:08:05.597 GCD[6663:357202] print queueName: GlobalUserInitiatedQueue index 5 for i = 1
2015-06-23 16:08:05.597 GCD[6663:357203] print queueName: GlobalUserInitiatedQueue index 6 for i = 2
2015-06-23 16:08:05.597 GCD[6663:357153] print queueName: GlobalUserInitiatedQueue index 7 for i = 0
2015-06-23 16:08:05.597 GCD[6663:357202] print queueName: GlobalUserInitiatedQueue index 6 for i = 1
2015-06-23 16:08:05.597 GCD[6663:357203] print queueName: GlobalUserInitiatedQueue index 7 for i = 2
2015-06-23 16:08:05.597 GCD[6663:357153] print queueName: GlobalUserInitiatedQueue index 8 for i = 0
2015-06-23 16:08:05.597 GCD[6663:357203] print queueName: GlobalUserInitiatedQueue index 8 for i = 2
2015-06-23 16:08:05.597 GCD[6663:357202] print queueName: GlobalUserInitiatedQueue index 7 for i = 1
2015-06-23 16:08:05.598 GCD[6663:357153] print queueName: GlobalUserInitiatedQueue index 9 for i = 0
2015-06-23 16:08:05.598 GCD[6663:357203] print queueName: GlobalUserInitiatedQueue index 9 for i = 2
2015-06-23 16:08:05.598 GCD[6663:357153] print queueName: GlobalUserInitiatedQueue index 10 for i = 0
2015-06-23 16:08:05.598 GCD[6663:357202] print queueName: GlobalUserInitiatedQueue index 8 for i = 1
2015-06-23 16:08:05.598 GCD[6663:357203] print queueName: GlobalUserInitiatedQueue index 10 for i = 2
2015-06-23 16:08:05.598 GCD[6663:357153] print queueName: GlobalUserInitiatedQueue index 11 for i = 0
2015-06-23 16:08:05.598 GCD[6663:357202] print queueName: GlobalUserInitiatedQueue index 9 for i = 1
2015-06-23 16:08:05.598 GCD[6663:357153] print queueName: GlobalUserInitiatedQueue index 12 for i = 0
2015-06-23 16:08:05.598 GCD[6663:357203] print queueName: GlobalUserInitiatedQueue index 11 for i = 2
2015-06-23 16:08:05.598 GCD[6663:357202] print queueName: GlobalUserInitiatedQueue index 10 for i = 1
2015-06-23 16:08:05.598 GCD[6663:357153] print queueName: GlobalUserInitiatedQueue index 13 for i = 0
2015-06-23 16:08:05.598 GCD[6663:357203] print queueName: GlobalUserInitiatedQueue index 12 for i = 2
2015-06-23 16:08:05.598 GCD[6663:357153] print queueName: GlobalUserInitiatedQueue index 14 for i = 0
2015-06-23 16:08:05.598 GCD[6663:357202] print queueName: GlobalUserInitiatedQueue index 11 for i = 1
2015-06-23 16:08:05.598 GCD[6663:357203] print queueName: GlobalUserInitiatedQueue index 13 for i = 2
2015-06-23 16:08:05.598 GCD[6663:357153] print queueName: GlobalUserInitiatedQueue index 15 for i = 0
2015-06-23 16:08:05.599 GCD[6663:357153] print queueName: GlobalUserInitiatedQueue index 16 for i = 0
2015-06-23 16:08:05.599 GCD[6663:357153] print queueName: GlobalUserInitiatedQueue index 17 for i = 0
2015-06-23 16:08:05.599 GCD[6663:357153] print queueName: GlobalUserInitiatedQueue index 18 for i = 0
2015-06-23 16:08:05.599 GCD[6663:357202] print queueName: GlobalUserInitiatedQueue index 12 for i = 1
2015-06-23 16:08:05.599 GCD[6663:357153] print queueName: GlobalUserInitiatedQueue index 19 for i = 0
2015-06-23 16:08:05.599 GCD[6663:357202] print queueName: GlobalUserInitiatedQueue index 13 for i = 1
2015-06-23 16:08:05.600 GCD[6663:357153] print queueName: GlobalUserInitiatedQueue index 20 for i = 0
2015-06-23 16:08:05.600 GCD[6663:357202] print queueName: GlobalUserInitiatedQueue index 14 for i = 1
2015-06-23 16:08:05.599 GCD[6663:357203] print queueName: GlobalUserInitiatedQueue index 14 for i = 2
2015-06-23 16:08:05.600 GCD[6663:357153] print queueName: GlobalUserInitiatedQueue index 21 for i = 0
2015-06-23 16:08:05.603 GCD[6663:357203] print queueName: GlobalUserInitiatedQueue index 15 for i = 2
2015-06-23 16:08:05.603 GCD[6663:357153] print queueName: GlobalUserInitiatedQueue index 22 for i = 0
2015-06-23 16:08:05.603 GCD[6663:357202] print queueName: GlobalUserInitiatedQueue index 15 for i = 1
2015-06-23 16:08:05.603 GCD[6663:357203] print queueName: GlobalUserInitiatedQueue index 16 for i = 2
2015-06-23 16:08:05.603 GCD[6663:357202] print queueName: GlobalUserInitiatedQueue index 16 for i = 1
2015-06-23 16:08:05.603 GCD[6663:357203] print queueName: GlobalUserInitiatedQueue index 17 for i = 2
2015-06-23 16:08:05.603 GCD[6663:357202] print queueName: GlobalUserInitiatedQueue index 17 for i = 1
2015-06-23 16:08:05.604 GCD[6663:357203] print queueName: GlobalUserInitiatedQueue index 18 for i = 2
2015-06-23 16:08:05.604 GCD[6663:357202] print queueName: GlobalUserInitiatedQueue index 18 for i = 1
2015-06-23 16:08:05.625 GCD[6663:357202] print queueName: GlobalUserInitiatedQueue index 19 for i = 1
2015-06-23 16:08:05.625 GCD[6663:357203] print queueName: GlobalUserInitiatedQueue index 19 for i = 2
2015-06-23 16:08:05.625 GCD[6663:357202] print queueName: GlobalUserInitiatedQueue index 20 for i = 1
2015-06-23 16:08:05.625 GCD[6663:357203] print queueName: GlobalUserInitiatedQueue index 20 for i = 2
2015-06-23 16:08:05.625 GCD[6663:357202] print queueName: GlobalUserInitiatedQueue index 21 for i = 1
2015-06-23 16:08:05.625 GCD[6663:357203] print queueName: GlobalUserInitiatedQueue index 21 for i = 2
2015-06-23 16:08:05.625 GCD[6663:357202] print queueName: GlobalUserInitiatedQueue index 22 for i = 1
2015-06-23 16:08:05.625 GCD[6663:357203] print queueName: GlobalUserInitiatedQueue index 22 for i = 2
2015-06-23 16:08:05.626 GCD[6663:357153] maxIndex: 10 -> queueName :GlobalUserInteractiveQueue
2015-06-23 16:08:05.626 GCD[6663:357202] maxIndex: 20 -> queueName :GlobalUserInteractiveQueue
2015-06-23 16:08:05.626 GCD[6663:357203] maxIndex: 14 -> queueName :GlobalUserInteractiveQueue
2015-06-23 16:08:05.626 GCD[6663:357153] print queueName: GlobalUserInteractiveQueue index 0 for i = 0
2015-06-23 16:08:05.626 GCD[6663:357202] print queueName: GlobalUserInteractiveQueue index 0 for i = 1
2015-06-23 16:08:05.626 GCD[6663:357203] print queueName: GlobalUserInteractiveQueue index 0 for i = 2
2015-06-23 16:08:05.626 GCD[6663:357153] print queueName: GlobalUserInteractiveQueue index 1 for i = 0
2015-06-23 16:08:05.626 GCD[6663:357202] print queueName: GlobalUserInteractiveQueue index 1 for i = 1
2015-06-23 16:08:05.626 GCD[6663:357203] print queueName: GlobalUserInteractiveQueue index 1 for i = 2
2015-06-23 16:08:05.626 GCD[6663:357153] print queueName: GlobalUserInteractiveQueue index 2 for i = 0
2015-06-23 16:08:05.626 GCD[6663:357202] print queueName: GlobalUserInteractiveQueue index 2 for i = 1
2015-06-23 16:08:05.626 GCD[6663:357203] print queueName: GlobalUserInteractiveQueue index 2 for i = 2
2015-06-23 16:08:05.627 GCD[6663:357153] print queueName: GlobalUserInteractiveQueue index 3 for i = 0
2015-06-23 16:08:05.641 GCD[6663:357153] print queueName: GlobalUserInteractiveQueue index 4 for i = 0
2015-06-23 16:08:05.641 GCD[6663:357203] print queueName: GlobalUserInteractiveQueue index 3 for i = 2
2015-06-23 16:08:05.641 GCD[6663:357153] print queueName: GlobalUserInteractiveQueue index 5 for i = 0
2015-06-23 16:08:05.641 GCD[6663:357203] print queueName: GlobalUserInteractiveQueue index 4 for i = 2
2015-06-23 16:08:05.641 GCD[6663:357202] print queueName: GlobalUserInteractiveQueue index 3 for i = 1
2015-06-23 16:08:05.642 GCD[6663:357153] print queueName: GlobalUserInteractiveQueue index 6 for i = 0
2015-06-23 16:08:05.642 GCD[6663:357203] print queueName: GlobalUserInteractiveQueue index 5 for i = 2
2015-06-23 16:08:05.642 GCD[6663:357202] print queueName: GlobalUserInteractiveQueue index 4 for i = 1
2015-06-23 16:08:05.642 GCD[6663:357153] print queueName: GlobalUserInteractiveQueue index 7 for i = 0
2015-06-23 16:08:05.642 GCD[6663:357203] print queueName: GlobalUserInteractiveQueue index 6 for i = 2
2015-06-23 16:08:05.658 GCD[6663:357153] print queueName: GlobalUserInteractiveQueue index 8 for i = 0
2015-06-23 16:08:05.658 GCD[6663:357202] print queueName: GlobalUserInteractiveQueue index 5 for i = 1
2015-06-23 16:08:05.658 GCD[6663:357203] print queueName: GlobalUserInteractiveQueue index 7 for i = 2
2015-06-23 16:08:05.658 GCD[6663:357153] print queueName: GlobalUserInteractiveQueue index 9 for i = 0
2015-06-23 16:08:05.658 GCD[6663:357203] print queueName: GlobalUserInteractiveQueue index 8 for i = 2
2015-06-23 16:08:05.658 GCD[6663:357202] print queueName: GlobalUserInteractiveQueue index 6 for i = 1
2015-06-23 16:08:05.659 GCD[6663:357153] print queueName: GlobalUserInteractiveQueue index 10 for i = 0
2015-06-23 16:08:05.659 GCD[6663:357202] print queueName: GlobalUserInteractiveQueue index 7 for i = 1
2015-06-23 16:08:05.659 GCD[6663:357203] print queueName: GlobalUserInteractiveQueue index 9 for i = 2
2015-06-23 16:08:05.659 GCD[6663:357153] print queueName: GlobalUserInteractiveQueue index 11 for i = 0
2015-06-23 16:08:05.662 GCD[6663:357203] print queueName: GlobalUserInteractiveQueue index 10 for i = 2
2015-06-23 16:08:05.662 GCD[6663:357202] print queueName: GlobalUserInteractiveQueue index 8 for i = 1
2015-06-23 16:08:05.662 GCD[6663:357153] print queueName: GlobalUserInteractiveQueue index 12 for i = 0
2015-06-23 16:08:05.662 GCD[6663:357203] print queueName: GlobalUserInteractiveQueue index 11 for i = 2
2015-06-23 16:08:05.662 GCD[6663:357202] print queueName: GlobalUserInteractiveQueue index 9 for i = 1
2015-06-23 16:08:05.662 GCD[6663:357153] print queueName: GlobalUserInteractiveQueue index 13 for i = 0
2015-06-23 16:08:05.662 GCD[6663:357202] print queueName: GlobalUserInteractiveQueue index 10 for i = 1
2015-06-23 16:08:05.662 GCD[6663:357203] print queueName: GlobalUserInteractiveQueue index 12 for i = 2
2015-06-23 16:08:05.662 GCD[6663:357202] print queueName: GlobalUserInteractiveQueue index 11 for i = 1
2015-06-23 16:08:05.663 GCD[6663:357203] print queueName: GlobalUserInteractiveQueue index 13 for i = 2
2015-06-23 16:08:05.663 GCD[6663:357202] print queueName: GlobalUserInteractiveQueue index 12 for i = 1
2015-06-23 16:08:05.663 GCD[6663:357202] print queueName: GlobalUserInteractiveQueue index 13 for i = 1
2015-06-23 16:08:05.663 GCD[6663:357153] maxIndex: 29 -> queueName :GlobalUtilityQueue
2015-06-23 16:08:05.663 GCD[6663:357153] print queueName: GlobalUtilityQueue index 0 for i = 0
2015-06-23 16:08:05.663 GCD[6663:357153] print queueName: GlobalUtilityQueue index 1 for i = 0
2015-06-23 16:08:05.663 GCD[6663:357153] print queueName: GlobalUtilityQueue index 2 for i = 0
2015-06-23 16:08:05.664 GCD[6663:357153] print queueName: GlobalUtilityQueue index 3 for i = 0
2015-06-23 16:08:05.664 GCD[6663:357153] maxIndex: 20 -> queueName :GlobalUtilityQueue
2015-06-23 16:08:05.664 GCD[6663:357153] print queueName: GlobalUtilityQueue index 0 for i = 2
2015-06-23 16:08:05.664 GCD[6663:357153] print queueName: GlobalUtilityQueue index 1 for i = 2
2015-06-23 16:08:05.664 GCD[6663:357153] print queueName: GlobalUtilityQueue index 2 for i = 2
2015-06-23 16:08:05.664 GCD[6663:357153] print queueName: GlobalUtilityQueue index 3 for i = 2
2015-06-23 16:08:05.663 GCD[6663:357202] maxIndex: 4 -> queueName :GlobalUtilityQueue
2015-06-23 16:08:05.664 GCD[6663:357153] print queueName: GlobalUtilityQueue index 4 for i = 2
2015-06-23 16:08:05.664 GCD[6663:357153] print queueName: GlobalUtilityQueue index 5 for i = 2
2015-06-23 16:08:05.665 GCD[6663:357153] print queueName: GlobalUtilityQueue index 6 for i = 2
2015-06-23 16:08:05.664 GCD[6663:357202] print queueName: GlobalUtilityQueue index 0 for i = 1
2015-06-23 16:08:05.665 GCD[6663:357153] print queueName: GlobalUtilityQueue index 7 for i = 2
2015-06-23 16:08:05.665 GCD[6663:357153] print queueName: GlobalUtilityQueue index 8 for i = 2
2015-06-23 16:08:05.665 GCD[6663:357202] print queueName: GlobalUtilityQueue index 1 for i = 1
2015-06-23 16:08:05.665 GCD[6663:357153] print queueName: GlobalUtilityQueue index 9 for i = 2
2015-06-23 16:08:05.675 GCD[6663:357153] print queueName: GlobalUtilityQueue index 10 for i = 2
2015-06-23 16:08:05.675 GCD[6663:357153] print queueName: GlobalUtilityQueue index 11 for i = 2
2015-06-23 16:08:05.675 GCD[6663:357153] print queueName: GlobalUtilityQueue index 12 for i = 2
2015-06-23 16:08:05.675 GCD[6663:357153] print queueName: GlobalUtilityQueue index 13 for i = 2
2015-06-23 16:08:05.676 GCD[6663:357153] print queueName: GlobalUtilityQueue index 14 for i = 2
2015-06-23 16:08:05.676 GCD[6663:357153] print queueName: GlobalUtilityQueue index 15 for i = 2
2015-06-23 16:08:05.676 GCD[6663:357153] print queueName: GlobalUtilityQueue index 16 for i = 2
2015-06-23 16:08:05.676 GCD[6663:357153] print queueName: GlobalUtilityQueue index 17 for i = 2
2015-06-23 16:08:05.676 GCD[6663:357153] print queueName: GlobalUtilityQueue index 18 for i = 2
2015-06-23 16:08:05.676 GCD[6663:357153] print queueName: GlobalUtilityQueue index 19 for i = 2
2015-06-23 16:08:05.675 GCD[6663:357202] print queueName: GlobalUtilityQueue index 2 for i = 1
2015-06-23 16:08:05.677 GCD[6663:357202] print queueName: GlobalUtilityQueue index 3 for i = 1
2015-06-23 16:08:05.677 GCD[6663:357202] print queueName: GlobalUtilityQueue index 4 for i = 1
2015-06-23 16:08:05.677 GCD[6663:357202] print queueName: GlobalUtilityQueue index 5 for i = 1
2015-06-23 16:08:05.677 GCD[6663:357202] print queueName: GlobalUtilityQueue index 6 for i = 1
2015-06-23 16:08:05.678 GCD[6663:357202] print queueName: GlobalUtilityQueue index 7 for i = 1
2015-06-23 16:08:05.680 GCD[6663:357202] print queueName: GlobalUtilityQueue index 8 for i = 1
2015-06-23 16:08:05.681 GCD[6663:357202] print queueName: GlobalUtilityQueue index 9 for i = 1
2015-06-23 16:08:05.681 GCD[6663:357202] print queueName: GlobalUtilityQueue index 10 for i = 1
2015-06-23 16:08:05.681 GCD[6663:357202] print queueName: GlobalUtilityQueue index 11 for i = 1
2015-06-23 16:08:05.681 GCD[6663:357202] print queueName: GlobalUtilityQueue index 12 for i = 1
2015-06-23 16:08:05.681 GCD[6663:357202] print queueName: GlobalUtilityQueue index 13 for i = 1
2015-06-23 16:08:05.681 GCD[6663:357202] print queueName: GlobalUtilityQueue index 14 for i = 1
2015-06-23 16:08:05.681 GCD[6663:357202] print queueName: GlobalUtilityQueue index 15 for i = 1
2015-06-23 16:08:05.682 GCD[6663:357202] print queueName: GlobalUtilityQueue index 16 for i = 1
2015-06-23 16:08:05.682 GCD[6663:357202] print queueName: GlobalUtilityQueue index 17 for i = 1
2015-06-23 16:08:05.682 GCD[6663:357202] print queueName: GlobalUtilityQueue index 18 for i = 1
2015-06-23 16:08:05.682 GCD[6663:357202] print queueName: GlobalUtilityQueue index 19 for i = 1
//
// ViewController.m
// GCD
//
// Created by Ankit Thakur on 6/23/15.
// Copyright (c) 2015 GCD. All rights reserved.
//
#import "ViewController.h"
#import "GCDUtils.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
dispatch_queue_t backgroundQueue = GlobalBackgroundQueue();
dispatch_queue_t backgroundQueue1 = GlobalUserInitiatedQueue();
dispatch_queue_t backgroundQueue2 = GlobalUserInteractiveQueue();
dispatch_queue_t backgroundQueue3 = GlobalUtilityQueue();
dispatch_queue_t backgroundQueue4 = GlobalMainQueue();
[self operateQueue:backgroundQueue withName:@"GlobalBackgroundQueue"];
[self operateQueue:backgroundQueue1 withName:@"GlobalUserInitiatedQueue"];
[self operateQueue:backgroundQueue2 withName:@"GlobalUserInteractiveQueue"];
[self operateQueue:backgroundQueue3 withName:@"GlobalUtilityQueue"];
[self operateQueue:backgroundQueue4 withName:@"backgroundQueue4"];
}
- (void) operateQueue:(dispatch_queue_t)queue withName:(NSString*)queueName{
__block int maxIndex = 10;
dispatch_group_t queueDownloadGroup = dispatch_group_create();
dispatch_apply(3, queue, ^(size_t i) {
maxIndex = arc4random() % 30;
NSLog(@"maxIndex: %d -> queueName :%@", maxIndex, queueName);
dispatch_group_enter(queueDownloadGroup);
int index = 0;
while (index < maxIndex) {
NSLog(@"print queueName: %@ index %d for i = %zu", queueName, index, i);
index++;
}
dispatch_group_leave(queueDownloadGroup);
});
dispatch_group_notify(queueDownloadGroup, dispatch_get_main_queue(), ^{
NSLog(@"group left process %@", queueName);
});
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment