ソースを参照

支持 reentrant

James 5 年 前
コミット
5fc2cb6ba7
1 ファイル変更12 行追加0 行削除
  1. 12 0
      src/main/java/com/jfinal/template/io/FastStringWriter.java

+ 12 - 0
src/main/java/com/jfinal/template/io/FastStringWriter.java

@@ -36,6 +36,8 @@ public class FastStringWriter extends Writer {
 	private char[] value;
 	private int len;
 	
+	boolean inUse;	// 支持 reentrant
+	
 	private static int MAX_BUFFER_SIZE = 1024 * 512;		// 1024 * 64;
 	
 	public static void setMaxBufferSize(int maxBufferSize) {
@@ -46,8 +48,14 @@ public class FastStringWriter extends Writer {
 		MAX_BUFFER_SIZE = maxBufferSize;
 	}
 	
+	public FastStringWriter init() {
+		inUse = true;
+		return this;
+	}
+	
 	@Override
 	public void close() /* throws IOException */ {
+		inUse = false;
 		len = 0;
 		
 		// 释放空间占用过大的缓存
@@ -56,6 +64,10 @@ public class FastStringWriter extends Writer {
 		}
 	}
 	
+	public boolean isInUse() {
+		return inUse;
+	}
+	
 	public String toString() {
 		return new String(value, 0, len);
 	}