添加delegate和observe

This commit is contained in:
tursom 2021-02-28 17:48:54 +08:00
parent a1e13580f4
commit a2ff3f38d4
2 changed files with 2 additions and 28 deletions

View File

@ -5,7 +5,7 @@ import cn.tursom.core.pool.DirectMemoryPool
import cn.tursom.datagram.AsyncDatagramClient
import cn.tursom.log.impl.Slf4jImpl
import cn.tursom.socket.NioClient
import cn.tursom.socket.server.BuffedNioServer
import cn.tursom.socket.server.BufferedNioServer
import kotlinx.coroutines.runBlocking
val logger = Slf4jImpl.getLogger()
@ -22,7 +22,7 @@ val echoHandler: suspend BufferedAsyncChannel.() -> Unit = {
fun main() {
val port = 12345
val pool = DirectMemoryPool(1024, 16)
val server = BuffedNioServer(port, pool, handler = echoHandler)
val server = BufferedNioServer(port, pool, handler = echoHandler)
//val server = LoopDatagramServer(port, protocol = object : NioProtocol {
// override fun handleRead(key: SelectionKey, nioThread: NioThread) {
// val datagramChannel = key.channel() as DatagramChannel

View File

@ -1,10 +1,7 @@
package cn.tursom.core.datastruct
import cn.tursom.core.randomInt
import cn.tursom.core.usingTime
import java.io.Serializable
import java.lang.reflect.Field
import java.util.concurrent.atomic.AtomicInteger
import java.util.concurrent.atomic.AtomicLongArray
import kotlin.random.Random
@ -229,26 +226,3 @@ class AtomicBitSet(beginSize: Long = 256, val defaultState: Boolean = false) : S
}
}
}
//val scand = AtomicInteger(0)
fun main() {
val size = 1000000
val bitSet = AtomicBitSet(size.toLong())
println(usingTime {
repeat(1000) {
bitSet.downAll()
repeat(size) {
val index = bitSet.getDownIndex()
bitSet.up(index)
repeat(randomInt(0, 3) / 2) {
val randomUpIndex = bitSet.randomUpIndex()
if (randomUpIndex >= 0) {
bitSet.down(randomUpIndex)
}
}
}
}
})
//println(scand.get() / 100)
}