Skip to content

Commit

Permalink
Fix #822
Browse files Browse the repository at this point in the history
Signed-off-by: Ross Allan <rallanpcl@gmail.com>
  • Loading branch information
LunNova committed Jul 8, 2013
1 parent 597fe5b commit 861a89b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
12 changes: 2 additions & 10 deletions src/common/nallar/tickthreading/global/ThreadLocals.java
Expand Up @@ -5,6 +5,8 @@
import java.util.HashSet;
import java.util.LinkedList;

import nallar.tickthreading.util.BooleanThreadLocal;

@SuppressWarnings ("UnusedDeclaration")
public class ThreadLocals {
public static final ThreadLocal redPowerBlockUpdateSet = new HashSetThreadLocal();
Expand Down Expand Up @@ -55,16 +57,6 @@ protected Object initialValue() {
}
}

private static class BooleanThreadLocal extends ThreadLocal {
BooleanThreadLocal() {
}

@Override
protected Object initialValue() {
return Boolean.FALSE;
}
}

public static class MapChunkTempByteArrayThreadLocal extends ThreadLocal<byte[]> {
@Override
public byte[] initialValue() {
Expand Down
9 changes: 2 additions & 7 deletions src/common/nallar/tickthreading/util/BooleanThreadLocal.java
Expand Up @@ -30,7 +30,6 @@ public Boolean initialValue() {
@Override
public void set(Boolean value) {
if (value == get()) {
Log.severe("Pointless repeat set on threadlocal", new Throwable());
return;
}
super.set(value);
Expand All @@ -42,16 +41,14 @@ public void set(Boolean value) {
return;
}
} while (true);
} else if (value == Boolean.FALSE) {
} else {
do {
int old = $.getIntVolatile(this, index);
int next = old - 1;
if ($.compareAndSwapInt(this, index, old, next)) {
return;
}
} while (true);
} else {
throw new Error("Must use Boolean.TRUE/FALSE.");
}
}

Expand All @@ -74,16 +71,14 @@ public Boolean getAndSet(Boolean value) {
return oldValue;
}
} while (true);
} else if (value == Boolean.FALSE) {
} else {
do {
int old = $.getIntVolatile(this, index);
int next = old - 1;
if ($.compareAndSwapInt(this, index, old, next)) {
return oldValue;
}
} while (true);
} else {
throw new Error("Must use Boolean.TRUE/FALSE.");
}
}

Expand Down

0 comments on commit 861a89b

Please sign in to comment.