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

cn.nukkit.utils.ThreadCache Maven / Gradle / Ivy

There is a newer version: 1.20.40-r1
Show newest version
package cn.nukkit.utils;

import cn.nukkit.nbt.stream.FastByteArrayOutputStream;

public class ThreadCache {
    public static void clean() {
        idArray.clean();
        dataArray.clean();
        byteCache6144.clean();
        boolCache4096.clean();
        charCache4096.clean();
        charCache4096v2.clean();
        fbaos.clean();
        binaryStream.clean();
        intCache256.clean();
        byteCache256.clean();
    }

    public static final IterableThreadLocal idArray = new IterableThreadLocal() {
        @Override
        public byte[][] init() {
            return new byte[16][];
        }
    };

    public static final IterableThreadLocal dataArray = new IterableThreadLocal() {
        @Override
        public byte[][] init() {
            return new byte[16][];
        }
    };

    public static final IterableThreadLocal byteCache6144 = new IterableThreadLocal() {
        @Override
        public byte[] init() {
            return new byte[6144];
        }
    };

    public static final IterableThreadLocal byteCache256 = new IterableThreadLocal() {
        @Override
        public byte[] init() {
            return new byte[256];
        }
    };

    public static final IterableThreadLocal boolCache4096 = new IterableThreadLocal() {
        @Override
        public boolean[] init() {
            return new boolean[4096];
        }
    };

    public static final IterableThreadLocal charCache4096v2 = new IterableThreadLocal() {
        @Override
        public char[] init() {
            return new char[4096];
        }
    };

    public static final IterableThreadLocal charCache4096 = new IterableThreadLocal() {
        @Override
        public char[] init() {
            return new char[4096];
        }
    };

    public static final IterableThreadLocal intCache256 = new IterableThreadLocal() {
        @Override
        public int[] init() {
            return new int[256];
        }
    };

    public static final IterableThreadLocal fbaos = new IterableThreadLocal() {
        @Override
        public FastByteArrayOutputStream init() {
            return new FastByteArrayOutputStream(1024);
        }
    };

    public static final IterableThreadLocal binaryStream = new IterableThreadLocal() {
        @Override
        public BinaryStream init() {
            return new BinaryStream();
        }
    };
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy