<commit_before>package org.voovan.tools.buffer;

import org.voovan.Global;
import org.voovan.tools.TEnv;
import org.voovan.tools.TFile;
import org.voovan.tools.TProperties;
import org.voovan.tools.TUnsafe;
import org.voovan.tools.exception.LargerThanMaxSizeException;
import org.voovan.tools.exception.MemoryReleasedException;
import org.voovan.tools.log.Logger;
import sun.misc.Unsafe;

import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.ReentrantLock;

/**
 * ByteBuffer双向通道
 *      默认: 非线程安全模式
 *
 * @author helyho
 *
 * Voovan Framework.
 * WebSite: https://github.com/helyho/Voovan
 * Licence: Apache v2 License
 */
public class ByteBufferChannel {
    private static int BYTEBUFFERCHANNEL_MAX_SIZE = TProperties.getInt("framework", "ByteBufferChannelMaxSize", 1024*1024*2);
    private volatile AtomicLong address = new AtomicLong(0);
    private Unsafe unsafe = TUnsafe.getUnsafe();
    private ByteBuffer byteBuffer;
    private volatile int size;
    private ReentrantLock lock;
    private AtomicBoolean borrowed = new AtomicBoolean(false);<commit_msg>fix: ByteBufferChannel 使用 volatile 修饰 byteBuffer<commit_after>package org.voovan.tools.buffer;

import org.voovan.Global;
import org.voovan.tools.TEnv;
import org.voovan.tools.TFile;
import org.voovan.tools.TProperties;
import org.voovan.tools.TUnsafe;
import org.voovan.tools.exception.LargerThanMaxSizeException;
import org.voovan.tools.exception.MemoryReleasedException;
import org.voovan.tools.log.Logger;
import sun.misc.Unsafe;

import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.ReentrantLock;

/**
 * ByteBuffer双向通道
 *      默认: 非线程安全模式
 *
 * @author helyho
 *
 * Voovan Framework.
 * WebSite: https://github.com/helyho/Voovan
 * Licence: Apache v2 License
 */
public class ByteBufferChannel {
    private static int BYTEBUFFERCHANNEL_MAX_SIZE = TProperties.getInt("framework", "ByteBufferChannelMaxSize", 1024*1024*2);
    private volatile AtomicLong address = new AtomicLong(0);
    private Unsafe unsafe = TUnsafe.getUnsafe();
    private volatile ByteBuffer byteBuffer;
    private volatile int size;
    private ReentrantLock lock;
    private AtomicBoolean borrowed = new AtomicBoolean(false);
{'fraction_non_alphanumeric': 0.0981060606060606, 'fraction_numerical': 0.008333333333333333, 'mean_word_length': 5.273159144893111, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2404669', 'n_tokens_mistral': 845, 'n_tokens_neox': 826, 'n_words': 173}