Shutdown is now atomic instead of volatile
This commit is contained in:
parent
cbfe51f746
commit
8e32e0980c
|
@ -145,8 +145,7 @@ abstract class EndPoint<CONNECTION : Connection> private constructor(val type: C
|
||||||
internal val endpointIsRunning = atomic(false)
|
internal val endpointIsRunning = atomic(false)
|
||||||
|
|
||||||
// this only prevents multiple shutdowns (in the event this close() is called multiple times)
|
// this only prevents multiple shutdowns (in the event this close() is called multiple times)
|
||||||
@Volatile
|
private var shutdown = atomic(false)
|
||||||
private var shutdown = false
|
|
||||||
internal val shutdownInProgress = atomic(false)
|
internal val shutdownInProgress = atomic(false)
|
||||||
|
|
||||||
@Volatile
|
@Volatile
|
||||||
|
@ -320,7 +319,7 @@ abstract class EndPoint<CONNECTION : Connection> private constructor(val type: C
|
||||||
origPollerLatch.countDown()
|
origPollerLatch.countDown()
|
||||||
|
|
||||||
endpointIsRunning.lazySet(true)
|
endpointIsRunning.lazySet(true)
|
||||||
shutdown = false
|
shutdown.lazySet(false)
|
||||||
shutdownEventPoller = false
|
shutdownEventPoller = false
|
||||||
|
|
||||||
// there are threading issues if there are client(s) and server's within the same JVM, where we have thread starvation
|
// there are threading issues if there are client(s) and server's within the same JVM, where we have thread starvation
|
||||||
|
@ -851,7 +850,7 @@ abstract class EndPoint<CONNECTION : Connection> private constructor(val type: C
|
||||||
* @return true if this endpoint has been closed
|
* @return true if this endpoint has been closed
|
||||||
*/
|
*/
|
||||||
fun isShutdown(): Boolean {
|
fun isShutdown(): Boolean {
|
||||||
return shutdown
|
return shutdown.value
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1050,7 +1049,7 @@ abstract class EndPoint<CONNECTION : Connection> private constructor(val type: C
|
||||||
// we might be restarting the aeron driver, so make sure it's closed.
|
// we might be restarting the aeron driver, so make sure it's closed.
|
||||||
aeronDriver.close()
|
aeronDriver.close()
|
||||||
|
|
||||||
shutdown = true
|
shutdown.lazySet(true)
|
||||||
|
|
||||||
// the shutdown here must be in the launchSequentially lambda, this way we can guarantee the driver is closed before we move on
|
// the shutdown here must be in the launchSequentially lambda, this way we can guarantee the driver is closed before we move on
|
||||||
shutdownInProgress.lazySet(false)
|
shutdownInProgress.lazySet(false)
|
||||||
|
@ -1079,7 +1078,7 @@ abstract class EndPoint<CONNECTION : Connection> private constructor(val type: C
|
||||||
shutdownLatch.countDown()
|
shutdownLatch.countDown()
|
||||||
pollerClosedLatch.countDown()
|
pollerClosedLatch.countDown()
|
||||||
endpointIsRunning.lazySet(false)
|
endpointIsRunning.lazySet(false)
|
||||||
shutdown = false
|
shutdown.lazySet(false)
|
||||||
shutdownEventPoller = false
|
shutdownEventPoller = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue