Rename #getBatchThread

This commit is contained in:
TheMode 2021-04-23 13:49:27 +02:00
parent 555cdb66de
commit 3035b3257d
2 changed files with 6 additions and 6 deletions

View File

@ -61,7 +61,7 @@ public class AcquirableEntity {
*/ */
public void acquire(@NotNull EntityConsumer consumer) { public void acquire(@NotNull EntityConsumer consumer) {
final Thread currentThread = Thread.currentThread(); final Thread currentThread = Thread.currentThread();
final TickThread elementThread = getHandler().getBatchThread(); final TickThread elementThread = getHandler().getTickThread();
Acquisition.acquire(currentThread, elementThread, () -> consumer.accept(unwrap())); Acquisition.acquire(currentThread, elementThread, () -> consumer.accept(unwrap()));
} }
@ -75,7 +75,7 @@ public class AcquirableEntity {
*/ */
public boolean tryAcquire(@NotNull EntityConsumer consumer) { public boolean tryAcquire(@NotNull EntityConsumer consumer) {
final Thread currentThread = Thread.currentThread(); final Thread currentThread = Thread.currentThread();
final TickThread elementThread = getHandler().getBatchThread(); final TickThread elementThread = getHandler().getTickThread();
if (Objects.equals(currentThread, elementThread)) { if (Objects.equals(currentThread, elementThread)) {
consumer.accept(unwrap()); consumer.accept(unwrap());
return true; return true;
@ -91,7 +91,7 @@ public class AcquirableEntity {
*/ */
public @Nullable Entity tryAcquire() { public @Nullable Entity tryAcquire() {
final Thread currentThread = Thread.currentThread(); final Thread currentThread = Thread.currentThread();
final TickThread elementThread = getHandler().getBatchThread(); final TickThread elementThread = getHandler().getTickThread();
if (Objects.equals(currentThread, elementThread)) { if (Objects.equals(currentThread, elementThread)) {
return unwrap(); return unwrap();
} }
@ -143,7 +143,7 @@ public class AcquirableEntity {
this.chunkEntry = chunkEntry; this.chunkEntry = chunkEntry;
} }
public TickThread getBatchThread() { public TickThread getTickThread() {
return chunkEntry != null ? chunkEntry.getThread() : null; return chunkEntry != null ? chunkEntry.getThread() : null;
} }
} }

View File

@ -155,7 +155,7 @@ public final class Acquisition {
for (AcquirableEntity element : collection) { for (AcquirableEntity element : collection) {
final Entity value = element.unwrap(); final Entity value = element.unwrap();
final TickThread elementThread = element.getHandler().getBatchThread(); final TickThread elementThread = element.getHandler().getTickThread();
if (currentThread == elementThread) { if (currentThread == elementThread) {
// The element is managed in the current thread, consumer can be immediately called // The element is managed in the current thread, consumer can be immediately called
consumer.accept(value); consumer.accept(value);
@ -175,7 +175,7 @@ public final class Acquisition {
Map<TickThread, List<Entity>> threadCacheMap = new HashMap<>(); Map<TickThread, List<Entity>> threadCacheMap = new HashMap<>();
for (AcquirableEntity acquirableEntity : collection) { for (AcquirableEntity acquirableEntity : collection) {
final Entity entity = acquirableEntity.unwrap(); final Entity entity = acquirableEntity.unwrap();
final TickThread elementThread = acquirableEntity.getHandler().getBatchThread(); final TickThread elementThread = acquirableEntity.getHandler().getTickThread();
List<Entity> threadCacheList = threadCacheMap.computeIfAbsent(elementThread, tickThread -> new ArrayList<>()); List<Entity> threadCacheList = threadCacheMap.computeIfAbsent(elementThread, tickThread -> new ArrayList<>());
threadCacheList.add(entity); threadCacheList.add(entity);