SectionBufferBuilderPool.java
net.minecraft.client.renderer.SectionBufferBuilderPool
信息
- 全限定名:net.minecraft.client.renderer.SectionBufferBuilderPool
- 类型:public class
- 包:net.minecraft.client.renderer
- 源码路径:src/main/java/net/minecraft/client/renderer/SectionBufferBuilderPool.java
- 起始行号:L14
- 职责:
TODO
字段/常量
-
LOGGER- 类型:
Logger - 修饰符:
private static final - 源码定位:
L15 - 说明:
TODO
- 类型:
-
freeBuffers- 类型:
ArrayBlockingQueue<SectionBufferBuilderPack> - 修饰符:
private final - 源码定位:
L16 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
private SectionBufferBuilderPool(List<SectionBufferBuilderPack> buffers) @ L18
- 构造器名:SectionBufferBuilderPool
- 源码定位:L18
- 修饰符:private
参数:
- buffers: List
说明:
TODO
方法
下面的方法块按源码顺序生成。
public static SectionBufferBuilderPool allocate(int maxWorkers) @ L23
- 方法名:allocate
- 源码定位:L23
- 返回类型:SectionBufferBuilderPool
- 修饰符:public static
参数:
- maxWorkers: int
说明:
TODO
public SectionBufferBuilderPack acquire() @ L44
- 方法名:acquire
- 源码定位:L44
- 返回类型:SectionBufferBuilderPack
- 修饰符:public
参数:
- 无
说明:
TODO
public void release(SectionBufferBuilderPack buffer) @ L48
- 方法名:release
- 源码定位:L48
- 返回类型:void
- 修饰符:public
参数:
- buffer: SectionBufferBuilderPack
说明:
TODO
public boolean isEmpty() @ L52
- 方法名:isEmpty
- 源码定位:L52
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
public int getFreeBufferCount() @ L56
- 方法名:getFreeBufferCount
- 源码定位:L56
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class SectionBufferBuilderPool {
private static final Logger LOGGER = LogUtils.getLogger();
private final ArrayBlockingQueue<SectionBufferBuilderPack> freeBuffers;
private SectionBufferBuilderPool(List<SectionBufferBuilderPack> buffers) {
this.freeBuffers = Queues.newArrayBlockingQueue(buffers.size());
this.freeBuffers.addAll(buffers);
}
public static SectionBufferBuilderPool allocate(int maxWorkers) {
int maxBuffers = Math.max(1, (int)(Runtime.getRuntime().maxMemory() * 0.3) / SectionBufferBuilderPack.TOTAL_BUFFERS_SIZE);
int targetBufferCount = Math.max(1, Math.min(maxWorkers, maxBuffers));
List<SectionBufferBuilderPack> buffers = new ArrayList<>(targetBufferCount);
try {
for (int i = 0; i < targetBufferCount; i++) {
buffers.add(new SectionBufferBuilderPack());
}
} catch (OutOfMemoryError var7) {
LOGGER.warn("Allocated only {}/{} buffers", buffers.size(), targetBufferCount);
int buffersToDrop = Math.min(buffers.size() * 2 / 3, buffers.size() - 1);
for (int i = 0; i < buffersToDrop; i++) {
buffers.remove(buffers.size() - 1).close();
}
}
return new SectionBufferBuilderPool(buffers);
}
public @Nullable SectionBufferBuilderPack acquire() {
return this.freeBuffers.poll();
}
public void release(SectionBufferBuilderPack buffer) {
this.freeBuffers.offer(buffer);
}
public boolean isEmpty() {
return this.freeBuffers.isEmpty();
}
public int getFreeBufferCount() {
return this.freeBuffers.size();
}
}引用的其他类
- SectionBufferBuilderPack
- 引用位置:
参数/字段/构造调用/返回值 - 关联成员:
SectionBufferBuilderPack()
- 引用位置: