Updated some comments about thread safety and fixed one easy case. Sean, please have...
authordswitkin <dswitkin@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Fri, 19 Jun 2009 19:08:31 +0000 (19:08 +0000)
committerdswitkin <dswitkin@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Fri, 19 Jun 2009 19:08:31 +0000 (19:08 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@973 59b500cc-1b3d-0410-9834-0bbf25fbcc57

core/src/com/google/zxing/common/BitSource.java
core/src/com/google/zxing/common/BlackPointEstimator.java
core/src/com/google/zxing/common/GridSampler.java
core/src/com/google/zxing/multi/qrcode/detector/MultiFinderPatternFinder.java
core/src/com/google/zxing/qrcode/detector/AlignmentPatternFinder.java
core/src/com/google/zxing/qrcode/detector/FinderPatternFinder.java

index f74d973..a61ac51 100755 (executable)
@@ -20,7 +20,8 @@ package com.google.zxing.common;
  * <p>This provides an easy abstraction to read bits at a time from a sequence of bytes, where the\r
  * number of bits read is not often a multiple of 8.</p>\r
  *\r
- * <p>This class is not thread-safe.</p>\r
+ * <p>This class is thread-safe but not reentrant. Unless the caller modifies the bytes array\r
+ * it passed in, in which case all bets are off.</p>\r
  *\r
  * @author Sean Owen\r
  */\r
index 0520d10..7ef79d6 100644 (file)
@@ -27,7 +27,7 @@ import com.google.zxing.ReaderException;
  * <p>For an interesting discussion of this issue, see\r
  * <a href="http://webdiis.unizar.es/~neira/12082/thresholding.pdf">this paper</a>.</p>\r
  *\r
- * NOTE: This class is not threadsafe.\r
+ * NOTE: This class is not thread-safe.\r
  *\r
  * @author Sean Owen\r
  * @author dswitkin@google.com (Daniel Switkin)\r
index 4cf2776..e15dd03 100644 (file)
@@ -34,7 +34,7 @@ import com.google.zxing.ReaderException;
  */
 public abstract class GridSampler {
 
-  private static GridSampler gridSampler = null;
+  private static GridSampler gridSampler = new DefaultGridSampler();
 
   /**
    * Sets the implementation of {@link GridSampler} used by the library. One global
@@ -43,7 +43,7 @@ public abstract class GridSampler {
    * in the whole lifetime of the JVM. For instance, an Android activity can swap in
    * an implementation that takes advantage of native platform libraries.
    * 
-   * @param newGridSampler
+   * @param newGridSampler The platform-specific object to install.
    */
   public static void setGridSampler(GridSampler newGridSampler) {
     if (newGridSampler == null) {
@@ -56,11 +56,6 @@ public abstract class GridSampler {
    * @return the current implementation of {@link GridSampler}
    */
   public static GridSampler getInstance() {
-    // No real point in trying to make this thread-safe;
-    // doesn't matter if a second instance is created
-    if (gridSampler == null) {
-      gridSampler = new DefaultGridSampler();
-    }
     return gridSampler;
   }
 
index c876686..4588df5 100644 (file)
@@ -35,6 +35,7 @@ import java.util.Vector;
  * markers at three corners of a QR Code.</p>\r
  *\r
  * <p>This class is not thread-safe and should not be reused.</p>\r
+ * TODO(dswitkin): Is this comment still true? I don't see any global variables for example.\r
  *\r
  * <p>In contrast to {@link FinderPatternFinder}, this class will return an array of all possible\r
  * QR code locations in the image.</p>\r
index 52e7896..9bc2423 100644 (file)
@@ -33,6 +33,7 @@ import java.util.Vector;
  * some code.</p>\r
  *\r
  * <p>This class is not thread-safe.</p>\r
+ * TODO(dswitkin): Is this still true?\r
  *\r
  * @author Sean Owen\r
  */\r
index e0b0dc9..23730bf 100755 (executable)
@@ -32,6 +32,7 @@ import java.util.Vector;
  * markers at three corners of a QR Code.</p>\r
  *\r
  * <p>This class is not thread-safe and should not be reused.</p>\r
+ * TODO(dswitkin): Is this still true?\r
  *\r
  * @author Sean Owen\r
  */\r