OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 DISPATCH_QUEUE_SERIAL); | 26 DISPATCH_QUEUE_SERIAL); |
27 }); | 27 }); |
28 } | 28 } |
29 | 29 |
30 + (void)dispatchAsyncOnType:(RTCDispatcherQueueType)dispatchType | 30 + (void)dispatchAsyncOnType:(RTCDispatcherQueueType)dispatchType |
31 block:(dispatch_block_t)block { | 31 block:(dispatch_block_t)block { |
32 dispatch_queue_t queue = [self dispatchQueueForType:dispatchType]; | 32 dispatch_queue_t queue = [self dispatchQueueForType:dispatchType]; |
33 dispatch_async(queue, block); | 33 dispatch_async(queue, block); |
34 } | 34 } |
35 | 35 |
| 36 + (BOOL)isOnQueueForType:(RTCDispatcherQueueType)dispatchType { |
| 37 dispatch_queue_t targetQueue = [self dispatchQueueForType:dispatchType]; |
| 38 const char* targetLabel = dispatch_queue_get_label(targetQueue); |
| 39 const char* currentLabel = dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LAB
EL); |
| 40 |
| 41 NSAssert(strlen(targetLabel) > 0, @"Label is required for the target queue."); |
| 42 NSAssert(strlen(currentLabel) > 0, @"Label is required for the current queue."
); |
| 43 |
| 44 return strcmp(targetLabel, currentLabel) == 0; |
| 45 } |
| 46 |
36 #pragma mark - Private | 47 #pragma mark - Private |
37 | 48 |
38 + (dispatch_queue_t)dispatchQueueForType:(RTCDispatcherQueueType)dispatchType { | 49 + (dispatch_queue_t)dispatchQueueForType:(RTCDispatcherQueueType)dispatchType { |
39 switch (dispatchType) { | 50 switch (dispatchType) { |
40 case RTCDispatcherTypeMain: | 51 case RTCDispatcherTypeMain: |
41 return dispatch_get_main_queue(); | 52 return dispatch_get_main_queue(); |
42 case RTCDispatcherTypeCaptureSession: | 53 case RTCDispatcherTypeCaptureSession: |
43 return kCaptureSessionQueue; | 54 return kCaptureSessionQueue; |
44 case RTCDispatcherTypeAudioSession: | 55 case RTCDispatcherTypeAudioSession: |
45 return kAudioSessionQueue; | 56 return kAudioSessionQueue; |
46 } | 57 } |
47 } | 58 } |
48 | 59 |
49 @end | 60 @end |
50 | 61 |
OLD | NEW |