Updated to use the conversant disruptor for the blocking pool implementation

This commit is contained in:
nathan 2019-06-14 14:03:58 +02:00
parent 8026dd0170
commit 5cb84d9c13
2 changed files with 9 additions and 34 deletions

View File

@ -14,11 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import java.time.Instant import java.time.Instant
import java.util.*
import kotlin.reflect.KMutableProperty
import kotlin.reflect.full.declaredMemberProperties
/////////////////////////////// ///////////////////////////////
////// PUBLISH TO SONATYPE / MAVEN CENTRAL ////// PUBLISH TO SONATYPE / MAVEN CENTRAL
@ -36,14 +32,14 @@ plugins {
`maven-publish` `maven-publish`
// close and release on sonatype // close and release on sonatype
id("io.codearte.nexus-staging") version "0.20.0" id("io.codearte.nexus-staging") version "0.21.0"
id("com.dorkbox.CrossCompile") version "1.0.1" id("com.dorkbox.CrossCompile") version "1.0.1"
id("com.dorkbox.Licensing") version "1.4" id("com.dorkbox.Licensing") version "1.4"
id("com.dorkbox.VersionUpdate") version "1.4.1" id("com.dorkbox.VersionUpdate") version "1.6"
id("com.dorkbox.GradleUtils") version "1.0" id("com.dorkbox.GradleUtils") version "1.2"
kotlin("jvm") version "1.3.21" kotlin("jvm") version "1.3.31"
} }
object Extras { object Extras {
@ -68,34 +64,11 @@ object Extras {
/////////////////////////////// ///////////////////////////////
///// assign 'Extras' ///// assign 'Extras'
/////////////////////////////// ///////////////////////////////
GradleUtils.load("$projectDir/../../gradle.properties", Extras)
description = Extras.description description = Extras.description
group = Extras.group group = Extras.group
version = Extras.version version = Extras.version
val propsFile = File("$projectDir/../../gradle.properties").normalize()
if (propsFile.canRead()) {
println("\tLoading custom property data from: [$propsFile]")
val props = Properties()
propsFile.inputStream().use {
props.load(it)
}
val extraProperties = Extras::class.declaredMemberProperties.filterIsInstance<KMutableProperty<String>>()
props.forEach { (k, v) -> run {
val key = k as String
val value = v as String
val member = extraProperties.find { it.name == key }
if (member != null) {
member.setter.call(Extras::class.objectInstance, value)
}
else {
project.extra.set(k, v)
}
}}
}
licensing { licensing {
license(License.APACHE_2) { license(License.APACHE_2) {
@ -162,6 +135,7 @@ tasks.compileJava.get().apply {
dependencies { dependencies {
api("org.slf4j:slf4j-api:1.7.25") api("org.slf4j:slf4j-api:1.7.25")
api("com.conversantmedia:disruptor:1.2.15")
} }
/////////////////////////////// ///////////////////////////////

View File

@ -15,9 +15,10 @@
*/ */
package dorkbox.objectPool; package dorkbox.objectPool;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue; import java.util.concurrent.BlockingQueue;
import com.conversantmedia.util.concurrent.DisruptorBlockingQueue;
/** /**
* A blocking pool of a specific size, where the entire pool is initially filled, and when the pool is empty, a * A blocking pool of a specific size, where the entire pool is initially filled, and when the pool is empty, a
* {@link ObjectPool#take()} will wait for a corresponding {@link ObjectPool#put(Object)}. * {@link ObjectPool#take()} will wait for a corresponding {@link ObjectPool#put(Object)}.
@ -29,7 +30,7 @@ class BlockingPool<T> extends ObjectPool<T> {
private final PoolableObject<T> poolableObject; private final PoolableObject<T> poolableObject;
BlockingPool(PoolableObject<T> poolableObject, int size) { BlockingPool(PoolableObject<T> poolableObject, int size) {
this(poolableObject, new ArrayBlockingQueue<T>(size), size); this(poolableObject, new DisruptorBlockingQueue<T>(size), size);
} }
BlockingPool(final PoolableObject<T> poolableObject, final BlockingQueue<T> queue, final int size) { BlockingPool(final PoolableObject<T> poolableObject, final BlockingQueue<T> queue, final int size) {