2 * Copyright 2007 The WebRTC Project Authors. All rights reserved.
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
10 // Helper function for using Cocoa with Posix threading.
13 #import <Foundation/Foundation.h>
15 #import "webrtc/base/maccocoathreadhelper.h"
19 // Cocoa must be "put into multithreading mode" before Cocoa functionality can
20 // be used on POSIX threads. The way to do that is to spawn one thread that may
22 void InitCocoaMultiThreading() {
23 if ([NSThread isMultiThreaded] == NO) {
24 // The sole purpose of this autorelease pool is to avoid a console
25 // message on Leopard that tells us we're autoreleasing the thread
26 // with no autorelease pool in place.
27 // Doing NSAutoreleasePool* hack = [[NSAutoreleasePool alloc] init];
28 // causes unused variable error.
29 NSAutoreleasePool* hack;
30 hack = [[NSAutoreleasePool alloc] init];
31 [NSThread detachNewThreadSelector:@selector(class)
32 toTarget:[NSObject class]
37 assert([NSThread isMultiThreaded]);