mirror of
https://github.com/Minestom/Minestom.git
synced 2024-06-24 13:34:53 +02:00
Cleanup
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
a0c38b94c6
commit
7f463cdf94
|
@ -88,7 +88,6 @@ public final class ThreadDispatcher {
|
|||
*/
|
||||
public void updateAndAwait(long time) {
|
||||
for (var entry : threadChunkMap.entrySet()) {
|
||||
final TickThread thread = entry.getKey();
|
||||
final Set<ChunkEntry> chunkEntries = entry.getValue();
|
||||
if (chunkEntries == null || chunkEntries.isEmpty()) {
|
||||
// Nothing to tick
|
||||
|
@ -96,9 +95,8 @@ public final class ThreadDispatcher {
|
|||
}
|
||||
// Execute tick
|
||||
this.phaser.register();
|
||||
thread.startTick(() -> {
|
||||
thread.updateEntries(chunkEntries);
|
||||
|
||||
final TickThread thread = entry.getKey();
|
||||
thread.startTick(chunkEntries, () -> {
|
||||
final ReentrantLock lock = thread.lock();
|
||||
lock.lock();
|
||||
for (ChunkEntry chunkEntry : chunkEntries) {
|
||||
|
|
|
@ -40,8 +40,9 @@ public final class TickThread extends Thread {
|
|||
}
|
||||
}
|
||||
|
||||
void startTick(@NotNull Runnable runnable) {
|
||||
void startTick(Collection<ThreadDispatcher.ChunkEntry> entries, Runnable runnable) {
|
||||
this.tickRunnable = runnable;
|
||||
this.entries = entries;
|
||||
LockSupport.unpark(this);
|
||||
}
|
||||
|
||||
|
@ -49,10 +50,6 @@ public final class TickThread extends Thread {
|
|||
return isTicking ? entries : Collections.emptyList();
|
||||
}
|
||||
|
||||
void updateEntries(Collection<ThreadDispatcher.ChunkEntry> entries) {
|
||||
this.entries = entries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the lock used to ensure the safety of entity acquisition.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue
Block a user