use of com.firenio.concurrent.RingSequence in project baseio by generallycloud.
the class NioEventLoopGroup method doStart.
@Override
protected void doStart() throws Exception {
this.channelIds = new RingSequence(0x1000, Integer.MAX_VALUE);
if (isEnableMemoryPool() && getAllocatorGroup() == null) {
if (!Native.EPOLL_AVAILABLE && Unsafe.UNSAFE_BUF_AVAILABLE) {
throw new IllegalArgumentException("Java(Nio) mode can not use unsafe memory");
}
if (memoryCapacity == 0) {
memoryCapacity = Runtime.getRuntime().maxMemory() / 64;
}
int memoryTypeId = preferHeap ? Unsafe.BUF_HEAP : Unsafe.getMemoryTypeId();
this.memoryCapacity = calcSuitableMemoryCapacity(memoryCapacity);
this.allocatorGroup = new ByteBufAllocatorGroup(getEventLoopSize(), memoryCapacity, memoryUnit, memoryTypeId);
}
Util.start(getAllocatorGroup());
super.doStart();
}
use of com.firenio.concurrent.RingSequence in project baseio by generallycloud.
the class TestRingSequence method test.
@Test
public void test() {
RingSequence s = new RingSequence(2, 5);
for (int i = 0; i < 4; i++) {
s.next();
}
Assert.expectTrue(s.next() == 3);
}
Aggregations