This commit is contained in:
tursom 2021-07-10 01:33:18 +08:00
parent 7a90928246
commit d86018ea4d
3 changed files with 7 additions and 4 deletions

View File

@ -12,6 +12,8 @@ class ThreadLocalSimpleDateFormat(
fun format(date: Date) = get().format(date)
fun parse(date: String) = get().parse(date)
fun now() = format(System.currentTimeMillis())
companion object {
val iso8601 = ThreadLocalSimpleDateFormat("YYYY-MM-dd'T'HH:mm:ssZZ")
val standard = ThreadLocalSimpleDateFormat("YYYY-MM-dd HH:mm:ss")

View File

@ -205,11 +205,12 @@ interface ByteBuffer : Closeable {
array.forEachIndex(index, index + size - 1, this::put)
}
fun put(inputStream: InputStream) {
if (hasArray) {
fun put(inputStream: InputStream): Int {
return if (hasArray) {
val read = inputStream.read(array, writeOffset, writeable)
if (read < 0) throw IOException("stream closed")
if (read < 0) throw IOException("stream closed")
writePosition += read
read
} else {
val buffer = ByteArray(10 * 1024)
val read = inputStream.read(buffer)

View File

@ -6,7 +6,7 @@ import java.util.concurrent.atomic.AtomicBoolean
/**
* 可自动申请新内存空间的内存池
* 线程安全
* 线程安全依赖于poolFactory提供的内存池的线程安全性
*/
class ExpandableMemoryPool(
val maxPoolCount: Int = -1,