Search in sources :

Example 1 with SimpleFence

use of io.xol.chunkstories.util.concurrency.SimpleFence in project chunkstories by Hugobros3.

the class ConverterWorkers method dropAll.

public void dropAll() {
    CompoundFence readyAll = new CompoundFence();
    CompoundFence doneAll = new CompoundFence();
    SimpleFence atSignal = new SimpleFence();
    for (int i = 0; i < workers.length; i++) {
        SimpleFence ready = new SimpleFence();
        readyAll.add(ready);
        SimpleFence done = new SimpleFence();
        doneAll.add(done);
        scheduleTask(new Task() {

            @Override
            protected boolean task(TaskExecutor taskExecutor) {
                ready.signal();
                atSignal.traverse();
                ConverterWorkerThread cwt = (ConverterWorkerThread) taskExecutor;
                for (ChunkHolder holder : cwt.registeredCS_Holders) {
                    holder.unregisterUser(cwt);
                    cwt.chunksAquired--;
                }
                for (Heightmap summary : cwt.registeredCS_Summaries) summary.unregisterUser(cwt);
                cwt.registeredCS_Summaries.clear();
                cwt.registeredCS_Holders.clear();
                done.signal();
                return true;
            }
        });
    }
    readyAll.traverse();
    atSignal.signal();
    doneAll.traverse();
}
Also used : CompoundFence(io.xol.chunkstories.util.concurrency.CompoundFence) Task(io.xol.chunkstories.api.workers.Task) TaskExecutor(io.xol.chunkstories.api.workers.TaskExecutor) Heightmap(io.xol.chunkstories.api.world.heightmap.Heightmap) ChunkHolder(io.xol.chunkstories.api.world.chunk.ChunkHolder) SimpleFence(io.xol.chunkstories.util.concurrency.SimpleFence)

Example 2 with SimpleFence

use of io.xol.chunkstories.util.concurrency.SimpleFence in project chunkstories by Hugobros3.

the class Client method reloadAssets.

@Override
public void reloadAssets() {
    SimpleFence waitForReload = new SimpleFence();
    Runnable reload = () -> {
        configuration.save();
        gameContent.reload();
        configuration.reload();
        gameWindow.getInputsManager().reload();
        gameWindow.getRenderingInterface().getFontRenderer().reloadFonts();
        configuration.load();
        waitForReload.signal();
    };
    if (gameWindow.isMainGLWindow())
        reload.run();
    else
        gameWindow.queueSynchronousTask(reload);
    waitForReload.traverse();
}
Also used : SimpleFence(io.xol.chunkstories.util.concurrency.SimpleFence)

Aggregations

SimpleFence (io.xol.chunkstories.util.concurrency.SimpleFence)2 Task (io.xol.chunkstories.api.workers.Task)1 TaskExecutor (io.xol.chunkstories.api.workers.TaskExecutor)1 ChunkHolder (io.xol.chunkstories.api.world.chunk.ChunkHolder)1 Heightmap (io.xol.chunkstories.api.world.heightmap.Heightmap)1 CompoundFence (io.xol.chunkstories.util.concurrency.CompoundFence)1