From a78dfcdadec1d18109fcd9ce77db82215e772ced Mon Sep 17 00:00:00 2001 From: dswitkin Date: Fri, 19 Jun 2009 19:08:31 +0000 Subject: [PATCH] Updated some comments about thread safety and fixed one easy case. Sean, please have a look. git-svn-id: http://zxing.googlecode.com/svn/trunk@973 59b500cc-1b3d-0410-9834-0bbf25fbcc57 --- core/src/com/google/zxing/common/BitSource.java | 3 ++- .../src/com/google/zxing/common/BlackPointEstimator.java | 2 +- core/src/com/google/zxing/common/GridSampler.java | 9 ++------- .../multi/qrcode/detector/MultiFinderPatternFinder.java | 1 + .../zxing/qrcode/detector/AlignmentPatternFinder.java | 1 + .../zxing/qrcode/detector/FinderPatternFinder.java | 1 + 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/core/src/com/google/zxing/common/BitSource.java b/core/src/com/google/zxing/common/BitSource.java index f74d9736..a61ac510 100755 --- a/core/src/com/google/zxing/common/BitSource.java +++ b/core/src/com/google/zxing/common/BitSource.java @@ -20,7 +20,8 @@ package com.google.zxing.common; *

This provides an easy abstraction to read bits at a time from a sequence of bytes, where the * number of bits read is not often a multiple of 8.

* - *

This class is not thread-safe.

+ *

This class is thread-safe but not reentrant. Unless the caller modifies the bytes array + * it passed in, in which case all bets are off.

* * @author Sean Owen */ diff --git a/core/src/com/google/zxing/common/BlackPointEstimator.java b/core/src/com/google/zxing/common/BlackPointEstimator.java index 0520d106..7ef79d65 100644 --- a/core/src/com/google/zxing/common/BlackPointEstimator.java +++ b/core/src/com/google/zxing/common/BlackPointEstimator.java @@ -27,7 +27,7 @@ import com.google.zxing.ReaderException; *

For an interesting discussion of this issue, see * this paper.

* - * NOTE: This class is not threadsafe. + * NOTE: This class is not thread-safe. * * @author Sean Owen * @author dswitkin@google.com (Daniel Switkin) diff --git a/core/src/com/google/zxing/common/GridSampler.java b/core/src/com/google/zxing/common/GridSampler.java index 4cf27763..e15dd03f 100644 --- a/core/src/com/google/zxing/common/GridSampler.java +++ b/core/src/com/google/zxing/common/GridSampler.java @@ -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; } diff --git a/core/src/com/google/zxing/multi/qrcode/detector/MultiFinderPatternFinder.java b/core/src/com/google/zxing/multi/qrcode/detector/MultiFinderPatternFinder.java index c8766868..4588df54 100644 --- a/core/src/com/google/zxing/multi/qrcode/detector/MultiFinderPatternFinder.java +++ b/core/src/com/google/zxing/multi/qrcode/detector/MultiFinderPatternFinder.java @@ -35,6 +35,7 @@ import java.util.Vector; * markers at three corners of a QR Code.

* *

This class is not thread-safe and should not be reused.

+ * TODO(dswitkin): Is this comment still true? I don't see any global variables for example. * *

In contrast to {@link FinderPatternFinder}, this class will return an array of all possible * QR code locations in the image.

diff --git a/core/src/com/google/zxing/qrcode/detector/AlignmentPatternFinder.java b/core/src/com/google/zxing/qrcode/detector/AlignmentPatternFinder.java index 52e7896e..9bc2423e 100644 --- a/core/src/com/google/zxing/qrcode/detector/AlignmentPatternFinder.java +++ b/core/src/com/google/zxing/qrcode/detector/AlignmentPatternFinder.java @@ -33,6 +33,7 @@ import java.util.Vector; * some code.

* *

This class is not thread-safe.

+ * TODO(dswitkin): Is this still true? * * @author Sean Owen */ diff --git a/core/src/com/google/zxing/qrcode/detector/FinderPatternFinder.java b/core/src/com/google/zxing/qrcode/detector/FinderPatternFinder.java index e0b0dc9f..23730bff 100755 --- a/core/src/com/google/zxing/qrcode/detector/FinderPatternFinder.java +++ b/core/src/com/google/zxing/qrcode/detector/FinderPatternFinder.java @@ -32,6 +32,7 @@ import java.util.Vector; * markers at three corners of a QR Code.

* *

This class is not thread-safe and should not be reused.

+ * TODO(dswitkin): Is this still true? * * @author Sean Owen */ -- 2.20.1