mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-13 22:43:59 +08:00
Reviewed By: achen1 Differential Revision: D7018869 fbshipit-source-id: beca45b1df9602ebbc9172091b24a2bf44e103f4
29 lines
664 B
Java
29 lines
664 B
Java
// Copyright 2004-present Facebook. All Rights Reserved.
|
|
|
|
package com.facebook.react.uimanager;
|
|
|
|
import com.facebook.yoga.YogaNode;
|
|
import com.facebook.react.common.ClearableSynchronizedPool;
|
|
|
|
/**
|
|
* Static holder for a recycling pool of YogaNodes.
|
|
*/
|
|
public class YogaNodePool {
|
|
|
|
private static final Object sInitLock = new Object();
|
|
private static ClearableSynchronizedPool<YogaNode> sPool;
|
|
|
|
public static ClearableSynchronizedPool<YogaNode> get() {
|
|
if (sPool != null) {
|
|
return sPool;
|
|
}
|
|
|
|
synchronized (sInitLock) {
|
|
if (sPool == null) {
|
|
sPool = new ClearableSynchronizedPool<>(1024);
|
|
}
|
|
return sPool;
|
|
}
|
|
}
|
|
}
|