# HG changeset patch # User Will Droste # Date 1415047615 21600 # Mon Nov 03 14:46:55 2014 -0600 # Branch remove_locks # Node ID 455923057c52d20a46aa4d8b0119033157d56f28 # Parent 3d2dbae23c5292b7f31ac4c92fa6d1afd8bd8eb2 Added high-scale-lib and then converted to using NonBlockingIdentityHashmap to reduce blocking in high multi-core applications diff -r 3d2dbae23c52 -r 455923057c52 .hgignore --- a/.hgignore Mon Aug 13 13:49:48 2012 -0700 +++ b/.hgignore Mon Nov 03 14:46:55 2014 -0600 @@ -28,3 +28,4 @@ cachedir dist profile.txt +.idea diff -r 3d2dbae23c52 -r 455923057c52 build.xml --- a/build.xml Mon Aug 13 13:49:48 2012 -0700 +++ b/build.xml Mon Nov 03 14:46:55 2014 -0600 @@ -186,6 +186,9 @@ + + + @@ -656,6 +659,7 @@ + diff -r 3d2dbae23c52 -r 455923057c52 extlibs/high-scale-lib-1.0.6.jar Binary file extlibs/high-scale-lib-1.0.6.jar has changed diff -r 3d2dbae23c52 -r 455923057c52 src/org/python/core/PyType.java --- a/src/org/python/core/PyType.java Mon Aug 13 13:49:48 2012 -0700 +++ b/src/org/python/core/PyType.java Mon Nov 03 14:46:55 2014 -0600 @@ -11,6 +11,8 @@ import java.util.Set; import java.util.concurrent.atomic.AtomicReferenceArray; +import org.cliffc.high_scale_lib.NonBlockingHashSet; +import org.cliffc.high_scale_lib.NonBlockingIdentityHashMap; import org.python.expose.ExposeAsSuperclass; import org.python.expose.ExposedDelete; import org.python.expose.ExposedGet; @@ -102,7 +104,7 @@ private static Set exposedTypes; /** Mapping of Java classes to their TypeBuilders. */ - private static Map, TypeBuilder> classToBuilder; + private static Map, TypeBuilder> classToBuilder = new NonBlockingIdentityHashMap, TypeBuilder>(); protected PyType(PyType subtype) { super(subtype); @@ -1271,13 +1273,13 @@ // are themselves synchronized. However, if we use Google Collections/Guava, // MapMaker only uses ConcurrentMap anyway - public static synchronized PyType fromClass(Class c) { + public static PyType fromClass(Class c) { return fromClass(c, true); } - public static synchronized PyType fromClass(Class c, boolean hardRef) { - if (class_to_type == null) { - class_to_type = new MapMaker().weakKeys().weakValues().makeMap(); + public static PyType fromClass(Class c, boolean hardRef) { + if (null == class_to_type) { + class_to_type = new NonBlockingIdentityHashMap, PyType>(); addFromClass(PyType.class, null); } PyType type = class_to_type.get(c); @@ -1311,8 +1313,8 @@ } } if (hardRef && result != null) { - if (exposedTypes == null) { - exposedTypes = Generic.set(); + if (null == exposedTypes) { + exposedTypes = new NonBlockingHashSet(); } exposedTypes.add(result) ; }