use of io.xol.chunkstories.util.concurrency.TrivialFence in project chunkstories by Hugobros3.
the class VertexBufferGL method uploadData.
/* (non-Javadoc)
* @see io.xol.engine.graphics.geometry.VertexBuffer#uploadData(io.xol.chunkstories.renderer.buffers.ByteBufferPool.RecyclableByteBuffer)
*/
@Override
public Fence uploadData(RecyclableByteBuffer dataToUpload) {
if (glID == -2)
throw new RuntimeException("Illegal operation : Attempted to upload data to a destroyed VerticesObject !");
// Queue for immediate upload
if (Client.getInstance().getGameWindow().isMainGLWindow()) {
Object replacing = waitingToUploadMainThread;
waitingToUploadMainThread = dataToUpload;
if (replacing != null && replacing != dataToUpload && replacing instanceof RecyclableByteBuffer) {
// System.out.println("Watch out, uploading two RecyclableByteBuffer in a row, the first one is getting recycled early to prevent locks");
RecyclableByteBuffer rcb = (RecyclableByteBuffer) replacing;
rcb.recycle();
}
dataSize = dataToUpload.accessByteBuffer().limit();
return new TrivialFence();
}
// This is a deffered call
return setAsyncDataPendingUpload(dataToUpload);
// pendingAsyncUpload = dataToUpload;
// return false;
}
use of io.xol.chunkstories.util.concurrency.TrivialFence in project chunkstories by Hugobros3.
the class ChunkLightBaker method requestLightningUpdate.
@Override
public Fence requestLightningUpdate() {
unbakedUpdates.incrementAndGet();
if (world instanceof WorldTool) {
WorldTool tool = (WorldTool) world;
if (!tool.isLightningEnabled()) {
// System.out.println("too soon");
return new TrivialFence();
}
}
Task fence;
taskLock.lock();
if (task == null || task.isDone() || task.isCancelled()) {
task = new TaskLightChunk(chunk, true);
chunk.getWorld().getGameContext().tasks().scheduleTask(task);
}
fence = task;
taskLock.unlock();
return fence;
}
Aggregations