mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-12 21:30:45 +01:00

This file has been causing problems for the build. ObjC was required for a few methods because autoreleasepools are necessary on new threads if those threads will be running objc code. This CL introduces a workaround by using ObjC runtime C APIs to create and drain autoreleasepools, but this comes with the cost of relying on an internal API that may break on future OS/clang releases. Bug: webrtc:9838 Change-Id: I18e765020c20c096c9ef8d80dfa82375ecb202ff Reviewed-on: https://webrtc-review.googlesource.com/c/105301 Commit-Queue: Kári Helgason <kthelgason@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25141}
24 lines
875 B
Text
24 lines
875 B
Text
/*
|
|
* Copyright 2018 The WebRTC Project Authors. All rights reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
#include "rtc_base/system/cocoa_threading.h"
|
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
#include "rtc_base/checks.h"
|
|
|
|
void InitCocoaMultiThreading() {
|
|
static BOOL is_cocoa_multithreaded = [NSThread isMultiThreaded];
|
|
if (!is_cocoa_multithreaded) {
|
|
// +[NSObject class] is idempotent.
|
|
[NSThread detachNewThreadSelector:@selector(class) toTarget:[NSObject class] withObject:nil];
|
|
is_cocoa_multithreaded = YES;
|
|
RTC_DCHECK([NSThread isMultiThreaded]);
|
|
}
|
|
}
|