mirror of
https://github.com/correl/mage.git
synced 2024-11-25 03:00:11 +00:00
Improved thread code
This commit is contained in:
parent
558eafce38
commit
1b54659c7d
1 changed files with 8 additions and 7 deletions
|
@ -25,6 +25,7 @@ import java.nio.file.attribute.BasicFileAttributes;
|
|||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicIntegerArray;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
|
@ -288,7 +289,7 @@ public final class ManaSymbols {
|
|||
// priority: SVG -> GIF
|
||||
// gif remain for backward compatibility
|
||||
|
||||
int[] iconErrors = new int[2]; // 0 - svg, 1 - gif
|
||||
AtomicIntegerArray iconErrors = new AtomicIntegerArray(2); // 0 - svg, 1 - gif
|
||||
|
||||
AtomicBoolean fileErrors = new AtomicBoolean(false);
|
||||
Map<String, BufferedImage> sizedSymbols = new ConcurrentHashMap<>();
|
||||
|
@ -313,7 +314,7 @@ public final class ManaSymbols {
|
|||
// gif
|
||||
if (image == null) {
|
||||
|
||||
iconErrors[0] += 1; // svg fail
|
||||
iconErrors.incrementAndGet(0); // svg fail
|
||||
|
||||
file = getSymbolFileNameAsGIF(symbol, size);
|
||||
if (file.exists()) {
|
||||
|
@ -325,21 +326,21 @@ public final class ManaSymbols {
|
|||
if (image != null) {
|
||||
sizedSymbols.put(symbol, image);
|
||||
} else {
|
||||
iconErrors[1] += 1; // gif fail
|
||||
iconErrors.incrementAndGet(1); // gif fail
|
||||
fileErrors.set(true);
|
||||
}
|
||||
});
|
||||
|
||||
// total errors
|
||||
String errorInfo = "";
|
||||
if (iconErrors[0] > 0) {
|
||||
errorInfo += "SVG fails - " + iconErrors[0];
|
||||
if (iconErrors.get(0) > 0) {
|
||||
errorInfo += "SVG fails - " + iconErrors.get(0);
|
||||
}
|
||||
if (iconErrors[1] > 0) {
|
||||
if (iconErrors.get(1) > 0) {
|
||||
if (!errorInfo.isEmpty()) {
|
||||
errorInfo += ", ";
|
||||
}
|
||||
errorInfo += "GIF fails - " + iconErrors[1];
|
||||
errorInfo += "GIF fails - " + iconErrors.get(1);
|
||||
}
|
||||
|
||||
if (!errorInfo.isEmpty()) {
|
||||
|
|
Loading…
Reference in a new issue