Skip to content

Commit

Permalink
build: prepare release otavia-0.4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
yankun1992 committed Sep 15, 2024
1 parent 9fe6186 commit 51a4ef4
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 40 deletions.
2 changes: 1 addition & 1 deletion build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ object ProjectInfo {
def repository = github.browsableRepository.get
def licenses = Seq(License.`Apache-2.0`)
def author = Seq("Yan Kun <yan_kun_1992@foxmail.com>")
def version = "0.4.4" // -SNAPSHOT
def version = "0.4.5" // -SNAPSHOT
def scalaVersion = "3.3.3"
def scoverageVersion = "1.4.0"
def buildTool = "mill"
Expand Down
12 changes: 6 additions & 6 deletions core/src/cc/otavia/core/system/ActorSystemImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ final private[core] class ActorSystemImpl(val name: String, val actorThreadFacto

private val timerImpl = new TimerImpl(this)

private val actorThreadPool: ActorThreadPool = new DefaultActorThreadPool(
this,
actorThreadFactory,
ActorSystem.ACTOR_THREAD_POOL_SIZE
)

private val generator = new AtomicLong(1)

private val beanManager = new BeanManager(this)
Expand All @@ -65,6 +59,12 @@ final private[core] class ActorSystemImpl(val name: String, val actorThreadFacto
private val transFactory: TransportFactory = TransportFactory.getTransportFactory(this)
private val chFactory: ChannelFactory = new ChannelFactory(transFactory)

private val actorThreadPool: ActorThreadPool = new DefaultActorThreadPool(
this,
actorThreadFactory,
ActorSystem.ACTOR_THREAD_POOL_SIZE
)

private val memoryMXBean: MemoryMXBean = ManagementFactory.getMemoryMXBean

@volatile private var busy: Boolean = false
Expand Down
4 changes: 1 addition & 3 deletions core/src/cc/otavia/core/system/ActorThread.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ import java.util.concurrent.ConcurrentLinkedQueue
import scala.collection.mutable
import scala.language.unsafeNulls

final class ActorThread(private[core] val system: ActorSystem) extends Thread() {

private val id = system.pool.nextThreadId()
final class ActorThread(private[core] val system: ActorSystem, private val id: Int) extends Thread() {

private val channelLaterTasks: mutable.ArrayDeque[Runnable] = mutable.ArrayDeque.empty

Expand Down
6 changes: 3 additions & 3 deletions core/src/cc/otavia/core/system/ActorThreadFactory.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ abstract class ActorThreadFactory {

def setSystem(actorSystem: ActorSystem): Unit

def newThread(): ActorThread
def newThread(index: Int): ActorThread

}

Expand All @@ -37,8 +37,8 @@ object ActorThreadFactory {

override def system: ActorSystem = sys

override def newThread(): ActorThread = {
val thread = new ActorThread(system)
override def newThread(index: Int): ActorThread = {
val thread = new ActorThread(system, index)
if (thread.isDaemon) thread.setDaemon(false)
if (thread.getPriority != Thread.NORM_PRIORITY) thread.setPriority(Thread.NORM_PRIORITY)
thread
Expand Down
2 changes: 1 addition & 1 deletion core/src/cc/otavia/core/system/ActorThreadPool.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ trait ActorThreadPool {

def nextThreadId(): Int

protected def createActorThread(): ActorThread
protected def createActorThread(index: Int): ActorThread

def next(channels: Boolean = false): ActorThread

Expand Down
31 changes: 9 additions & 22 deletions core/src/cc/otavia/core/system/DefaultActorThreadPool.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package cc.otavia.core.system

import java.util.concurrent.atomic.AtomicBoolean

class DefaultActorThreadPool(
override val system: ActorSystem,
override val actorThreadFactory: ActorThreadFactory,
Expand All @@ -28,44 +26,33 @@ class DefaultActorThreadPool(

private val threads: Array[ActorThread] = new Array[ActorThread](size)

@volatile private var inited: Boolean = false

private val normalSelector = new TilingThreadSelector(threads)
private val ioSelector = new TilingThreadSelector(threads)

private def init(): Unit = {
for (index <- 0 until size) {
val thread = createActorThread()
threads(index) = thread
thread.start()
}
inited = true
init()

private def init(): Unit = for (index <- 0 until size) {
val thread = createActorThread(index)
threads(index) = thread
thread.start()
}

override def isInit: Boolean = inited
override def isInit: Boolean = true

override def nextThreadId(): Int = {
cursor += 1
cursor
}

override protected def createActorThread(): ActorThread = {
actorThreadFactory.newThread()
override protected def createActorThread(index: Int): ActorThread = {
actorThreadFactory.newThread(index)
}

override def next(channels: Boolean): ActorThread = {
if (!inited) {
this.synchronized { init() }
}
if (!channels) normalSelector.select() else ioSelector.select()
}

override def nexts(num: Int, channels: Boolean): Seq[ActorThread] = {
if (!inited) {
this.synchronized {
init()
}
}
if (!channels) normalSelector.select(num) else ioSelector.select(num)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ object PostgresConnectOptions {
private val DEFAULT_DATABASE = "db"
private val DEFAULT_USER = "user"
private val DEFAULT_PASSWORD = "pass"
private val DEFAULT_PIPELINING_LIMIT: Int = 10240
private val DEFAULT_PIPELINING_LIMIT: Int = 102400
private val DEFAULT_SSL_MODE: SslMode = SslMode.DISABLE
private val DEFAULT_USE_LAYER_7_PROXY = false
private val DEFAULT_PROPERTIES: Map[String, String] = Map(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package cc.otavia.postgres

import cc.otavia.buffer.Buffer
import cc.otavia.buffer.{Buffer, BufferUtils}
import cc.otavia.postgres.impl.{PreparedStatement, RowValueCodec}
import cc.otavia.sql.RowWriter

Expand All @@ -24,11 +24,17 @@ protected class PostgresRowWriter extends RowWriter {

override def writeNull(index: Int): Unit = buffer.writeInt(-1)

override def writeChar(value: Char, index: Int): Unit = ???
override def writeChar(value: Char, index: Int): Unit = {
buffer.writeInt(0)
???
}

override def writeString(value: String, index: Int): Unit = ???

override def writeBoolean(value: Boolean, index: Int): Unit = ???
override def writeBoolean(value: Boolean, index: Int): Unit = {
buffer.writeInt(1)
buffer.writeBoolean(value)
}

override def writeByte(value: Byte, index: Int): Unit = ???

Expand Down

0 comments on commit 51a4ef4

Please sign in to comment.