AeronContext now implements Closable
This commit is contained in:
parent
1ab11f7c78
commit
9969dcd9b8
@ -5,6 +5,7 @@ import dorkbox.util.NamedThreadFactory
|
|||||||
import io.aeron.driver.MediaDriver
|
import io.aeron.driver.MediaDriver
|
||||||
import io.aeron.exceptions.DriverTimeoutException
|
import io.aeron.exceptions.DriverTimeoutException
|
||||||
import mu.KLogger
|
import mu.KLogger
|
||||||
|
import java.io.Closeable
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.concurrent.locks.*
|
import java.util.concurrent.locks.*
|
||||||
|
|
||||||
@ -13,15 +14,7 @@ class AeronContext(
|
|||||||
val type: Class<*> = AeronDriver::class.java,
|
val type: Class<*> = AeronDriver::class.java,
|
||||||
val logger: KLogger,
|
val logger: KLogger,
|
||||||
aeronErrorHandler: (error: Throwable) -> Unit
|
aeronErrorHandler: (error: Throwable) -> Unit
|
||||||
) {
|
) : Closeable {
|
||||||
fun close() {
|
|
||||||
context.close()
|
|
||||||
|
|
||||||
// Destroys this thread group and all of its subgroups.
|
|
||||||
// This thread group must be empty, indicating that all threads that had been in this thread group have since stopped.
|
|
||||||
threadFactory.group.destroy()
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private fun create(
|
private fun create(
|
||||||
config: Configuration,
|
config: Configuration,
|
||||||
@ -184,7 +177,7 @@ class AeronContext(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug { "Aeron directory: '${context.aeronDirectory()}'" }
|
logger.debug { "Aeron context created. Directory: '${context.aeronDirectory()}'" }
|
||||||
|
|
||||||
this.context = context
|
this.context = context
|
||||||
}
|
}
|
||||||
@ -192,4 +185,12 @@ class AeronContext(
|
|||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return context.toString()
|
return context.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun close() {
|
||||||
|
context.close()
|
||||||
|
|
||||||
|
// Destroys this thread group and all of its subgroups.
|
||||||
|
// This thread group must be empty, indicating that all threads that had been in this thread group have since stopped.
|
||||||
|
threadFactory.group.destroy()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user