All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alanpoi.etactivity.protocol.ByteBufCache Maven / Gradle / Ivy

There is a newer version: 1.3.8
Show newest version
package com.alanpoi.etactivity.protocol;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;

import java.util.ArrayDeque;
import java.util.Queue;

public class ByteBufCache {
    private static Queue byteBufCache=new ArrayDeque<>();

    public static void init(){
        for (int i=0;i<5;i++){
            byteBufCache.add(Unpooled.buffer(32));
        }
    }

    public static synchronized ByteBuf getByteBuf(){
        if(byteBufCache.size()<=0){
            init();
        }
        return byteBufCache.poll();
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy