io.altoo.serialization.kryo.scala.SerializerPool.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scala-kryo-serialization_2.12 Show documentation
Show all versions of scala-kryo-serialization_2.12 Show documentation
pekko-serialization implementation using kryo - core implementation
The newest version!
package io.altoo.serialization.kryo.scala
/**
* Returns a SerializerPool, useful to reduce GC overhead.
*
* @param queueBuilder queue builder.
* @param newInstance Serializer instance builder.
*/
private[kryo] class SerializerPool(queueBuilder: DefaultQueueBuilder, newInstance: () => KryoSerializerBackend) {
private val pool = queueBuilder.build[KryoSerializerBackend]
def fetch(): KryoSerializerBackend = {
pool.poll() match {
case null => newInstance()
case o => o
}
}
def release(o: KryoSerializerBackend): Unit = {
pool.offer(o)
}
def add(o: KryoSerializerBackend): Unit = {
pool.add(o)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy