1/** 2 * Copyright (c) 2015-present, Facebook, Inc. 3 * 4 * This source code is licensed under the MIT license found in the 5 * LICENSE file in the root directory of this source tree. 6 */ 7 8#import <Foundation/Foundation.h> 9#import "RNCWKProcessPoolManager.h" 10 11@interface RNCWKProcessPoolManager() { 12 WKProcessPool *_sharedProcessPool; 13 NSMutableDictionary<NSString *, WKProcessPool *> *_pools; 14} 15@end 16 17@implementation RNCWKProcessPoolManager 18 19- (instancetype)init 20{ 21 if (self = [super init]) { 22 _pools = [NSMutableDictionary new]; 23 } 24 return self; 25} 26 27- (WKProcessPool *)sharedProcessPoolForScopeKey:(NSString *)scopeKey 28{ 29 if (!scopeKey) { 30 return [self sharedProcessPool]; 31 } 32 if (!_pools[scopeKey]) { 33 _pools[scopeKey] = [[WKProcessPool alloc] init]; 34 } 35 return _pools[scopeKey]; 36} 37 38 39+ (id) sharedManager { 40 static RNCWKProcessPoolManager *_sharedManager = nil; 41 @synchronized(self) { 42 if(_sharedManager == nil) { 43 _sharedManager = [[super alloc] init]; 44 } 45 return _sharedManager; 46 } 47} 48 49- (WKProcessPool *)sharedProcessPool { 50 if (!_sharedProcessPool) { 51 _sharedProcessPool = [[WKProcessPool alloc] init]; 52 } 53 return _sharedProcessPool; 54} 55 56@end 57 58