**breaking:** remove YGNodeGetInstanceCount
Summary: @public `YGNodeGetInstanceCount` was only ever meant for tests, and caused data races in multi-threaded environments. It was completely replaced with event-based counting for tests. Here we remove public API around the counter, and the counter itself. Reviewed By: SidharthGuglani Differential Revision: D15174857 fbshipit-source-id: 228e85da565bac9e8485121e956a2e41910b11c8
This commit is contained in:
committed by
Facebook Github Bot
parent
9e20dfeea1
commit
e96a09e5ff
@@ -43,9 +43,6 @@ namespace Facebook.Yoga
|
|||||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern void YGConfigFree(IntPtr node);
|
public static extern void YGConfigFree(IntPtr node);
|
||||||
|
|
||||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
public static extern int YGNodeGetInstanceCount();
|
|
||||||
|
|
||||||
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
[DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern int YGConfigGetInstanceCount();
|
public static extern int YGConfigGetInstanceCount();
|
||||||
|
|
||||||
|
@@ -673,10 +673,5 @@ namespace Facebook.Yoga
|
|||||||
return _children != null ? ((IEnumerable<YogaNode>)_children).GetEnumerator() :
|
return _children != null ? ((IEnumerable<YogaNode>)_children).GetEnumerator() :
|
||||||
System.Linq.Enumerable.Empty<YogaNode>().GetEnumerator();
|
System.Linq.Enumerable.Empty<YogaNode>().GetEnumerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int GetInstanceCount()
|
|
||||||
{
|
|
||||||
return Native.YGNodeGetInstanceCount();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -28,7 +28,6 @@ public class YogaNative {
|
|||||||
|
|
||||||
|
|
||||||
// YGNode related
|
// YGNode related
|
||||||
static native int jni_YGNodeGetInstanceCount();
|
|
||||||
static native long jni_YGNodeNew(boolean useBatchingForLayoutOutputs);
|
static native long jni_YGNodeNew(boolean useBatchingForLayoutOutputs);
|
||||||
static native long jni_YGNodeNewWithConfig(long configPointer, boolean useBatchingForLayoutOutputs);
|
static native long jni_YGNodeNewWithConfig(long configPointer, boolean useBatchingForLayoutOutputs);
|
||||||
static native void jni_YGNodeFree(long nativePointer);
|
static native void jni_YGNodeFree(long nativePointer);
|
||||||
|
@@ -938,10 +938,6 @@ void jni_YGNodeSetStyleInputs(
|
|||||||
YGNodeSetStyleInputs(_jlong2YGNodeRef(nativePointer), result, size);
|
YGNodeSetStyleInputs(_jlong2YGNodeRef(nativePointer), result, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
jint jni_YGNodeGetInstanceCount() {
|
|
||||||
return YGNodeGetInstanceCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
jlong jni_YGNodeStyleGetMargin(jlong nativePointer, jint edge) {
|
jlong jni_YGNodeStyleGetMargin(jlong nativePointer, jint edge) {
|
||||||
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
|
YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer);
|
||||||
if (!YGNodeEdges{yogaNodeRef}.has(YGNodeEdges::MARGIN)) {
|
if (!YGNodeEdges{yogaNodeRef}.has(YGNodeEdges::MARGIN)) {
|
||||||
@@ -1105,7 +1101,6 @@ jint JNI_OnLoad(JavaVM* vm, void*) {
|
|||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxHeightPercent),
|
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxHeightPercent),
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAspectRatio),
|
YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAspectRatio),
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAspectRatio),
|
YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAspectRatio),
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodeGetInstanceCount),
|
|
||||||
YGMakeCriticalNativeMethod(jni_YGNodePrint),
|
YGMakeCriticalNativeMethod(jni_YGNodePrint),
|
||||||
YGMakeNativeMethod(jni_YGNodeClone),
|
YGMakeNativeMethod(jni_YGNodeClone),
|
||||||
YGMakeNativeMethod(jni_YGNodeSetStyleInputs),
|
YGMakeNativeMethod(jni_YGNodeSetStyleInputs),
|
||||||
|
@@ -1,13 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the LICENSE
|
|
||||||
* file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
#include <yoga/Yoga.h>
|
|
||||||
|
|
||||||
#include "./global.hh"
|
|
||||||
|
|
||||||
unsigned getInstanceCount(void) {
|
|
||||||
return YGNodeGetInstanceCount();
|
|
||||||
}
|
|
@@ -206,14 +206,12 @@ void YGNodeMarkDirtyAndPropogateToDescendants(const YGNodeRef node) {
|
|||||||
return node->markDirtyAndPropogateDownwards();
|
return node->markDirtyAndPropogateDownwards();
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t gNodeInstanceCount = 0;
|
|
||||||
int32_t gConfigInstanceCount = 0;
|
int32_t gConfigInstanceCount = 0;
|
||||||
|
|
||||||
WIN_EXPORT YGNodeRef YGNodeNewWithConfig(const YGConfigRef config) {
|
WIN_EXPORT YGNodeRef YGNodeNewWithConfig(const YGConfigRef config) {
|
||||||
const YGNodeRef node = new YGNode();
|
const YGNodeRef node = new YGNode();
|
||||||
YGAssertWithConfig(
|
YGAssertWithConfig(
|
||||||
config, node != nullptr, "Could not allocate memory for node");
|
config, node != nullptr, "Could not allocate memory for node");
|
||||||
gNodeInstanceCount++;
|
|
||||||
#ifdef YG_ENABLE_EVENTS
|
#ifdef YG_ENABLE_EVENTS
|
||||||
Event::publish<Event::NodeAllocation>(node, {config});
|
Event::publish<Event::NodeAllocation>(node, {config});
|
||||||
#endif
|
#endif
|
||||||
@@ -241,7 +239,6 @@ YGNodeRef YGNodeClone(YGNodeRef oldNode) {
|
|||||||
oldNode->getConfig(),
|
oldNode->getConfig(),
|
||||||
node != nullptr,
|
node != nullptr,
|
||||||
"Could not allocate memory for node");
|
"Could not allocate memory for node");
|
||||||
gNodeInstanceCount++;
|
|
||||||
#ifdef YG_ENABLE_EVENTS
|
#ifdef YG_ENABLE_EVENTS
|
||||||
Event::publish<Event::NodeAllocation>(node, {node->getConfig()});
|
Event::publish<Event::NodeAllocation>(node, {node->getConfig()});
|
||||||
#endif
|
#endif
|
||||||
@@ -295,7 +292,6 @@ void YGNodeFree(const YGNodeRef node) {
|
|||||||
Event::publish<Event::NodeDeallocation>(node, {node->getConfig()});
|
Event::publish<Event::NodeDeallocation>(node, {node->getConfig()});
|
||||||
#endif
|
#endif
|
||||||
delete node;
|
delete node;
|
||||||
gNodeInstanceCount--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void YGConfigFreeRecursive(const YGNodeRef root) {
|
static void YGConfigFreeRecursive(const YGNodeRef root) {
|
||||||
@@ -337,10 +333,6 @@ void YGNodeReset(YGNodeRef node) {
|
|||||||
node->reset();
|
node->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t YGNodeGetInstanceCount(void) {
|
|
||||||
return gNodeInstanceCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t YGConfigGetInstanceCount(void) {
|
int32_t YGConfigGetInstanceCount(void) {
|
||||||
return gConfigInstanceCount;
|
return gConfigInstanceCount;
|
||||||
}
|
}
|
||||||
|
@@ -62,7 +62,6 @@ WIN_EXPORT void YGNodeFreeRecursiveWithCleanupFunc(
|
|||||||
YGNodeCleanupFunc cleanup);
|
YGNodeCleanupFunc cleanup);
|
||||||
WIN_EXPORT void YGNodeFreeRecursive(YGNodeRef node);
|
WIN_EXPORT void YGNodeFreeRecursive(YGNodeRef node);
|
||||||
WIN_EXPORT void YGNodeReset(YGNodeRef node);
|
WIN_EXPORT void YGNodeReset(YGNodeRef node);
|
||||||
WIN_EXPORT int32_t YGNodeGetInstanceCount(void);
|
|
||||||
|
|
||||||
WIN_EXPORT void YGNodeInsertChild(
|
WIN_EXPORT void YGNodeInsertChild(
|
||||||
YGNodeRef node,
|
YGNodeRef node,
|
||||||
|
Reference in New Issue
Block a user