Updated some comments about thread safety and fixed one easy case. Sean, please have a look.

git-svn-id: https://zxing.googlecode.com/svn/trunk@973 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
dswitkin 2009-06-19 19:08:31 +00:00
parent 63a1dc62a3
commit 0c3a4b4b5a
6 changed files with 8 additions and 9 deletions

View file

@ -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 * <p>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.</p> * number of bits read is not often a multiple of 8.</p>
* *
* <p>This class is not thread-safe.</p> * <p>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.</p>
* *
* @author Sean Owen * @author Sean Owen
*/ */

View file

@ -27,7 +27,7 @@ import com.google.zxing.ReaderException;
* <p>For an interesting discussion of this issue, see * <p>For an interesting discussion of this issue, see
* <a href="http://webdiis.unizar.es/~neira/12082/thresholding.pdf">this paper</a>.</p> * <a href="http://webdiis.unizar.es/~neira/12082/thresholding.pdf">this paper</a>.</p>
* *
* NOTE: This class is not threadsafe. * NOTE: This class is not thread-safe.
* *
* @author Sean Owen * @author Sean Owen
* @author dswitkin@google.com (Daniel Switkin) * @author dswitkin@google.com (Daniel Switkin)

View file

@ -34,7 +34,7 @@ import com.google.zxing.ReaderException;
*/ */
public abstract class GridSampler { 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 * 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 * in the whole lifetime of the JVM. For instance, an Android activity can swap in
* an implementation that takes advantage of native platform libraries. * 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) { public static void setGridSampler(GridSampler newGridSampler) {
if (newGridSampler == null) { if (newGridSampler == null) {
@ -56,11 +56,6 @@ public abstract class GridSampler {
* @return the current implementation of {@link GridSampler} * @return the current implementation of {@link GridSampler}
*/ */
public static GridSampler getInstance() { 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; return gridSampler;
} }

View file

@ -35,6 +35,7 @@ import java.util.Vector;
* markers at three corners of a QR Code.</p> * markers at three corners of a QR Code.</p>
* *
* <p>This class is not thread-safe and should not be reused.</p> * <p>This class is not thread-safe and should not be reused.</p>
* TODO(dswitkin): Is this comment still true? I don't see any global variables for example.
* *
* <p>In contrast to {@link FinderPatternFinder}, this class will return an array of all possible * <p>In contrast to {@link FinderPatternFinder}, this class will return an array of all possible
* QR code locations in the image.</p> * QR code locations in the image.</p>

View file

@ -33,6 +33,7 @@ import java.util.Vector;
* some code.</p> * some code.</p>
* *
* <p>This class is not thread-safe.</p> * <p>This class is not thread-safe.</p>
* TODO(dswitkin): Is this still true?
* *
* @author Sean Owen * @author Sean Owen
*/ */

View file

@ -32,6 +32,7 @@ import java.util.Vector;
* markers at three corners of a QR Code.</p> * markers at three corners of a QR Code.</p>
* *
* <p>This class is not thread-safe and should not be reused.</p> * <p>This class is not thread-safe and should not be reused.</p>
* TODO(dswitkin): Is this still true?
* *
* @author Sean Owen * @author Sean Owen
*/ */