Tweaked how waiting for close works

This commit is contained in:
Robinson 2023-08-09 22:13:12 -06:00
parent 2b5e943369
commit 07e1da3660
No known key found for this signature in database
GPG Key ID: 8E7DB78588BD6F5C
1 changed files with 7 additions and 1 deletions

View File

@ -155,6 +155,12 @@ abstract class EndPoint<CONNECTION : Connection> private constructor(val type: C
@Volatile
internal var pollerClosedLatch = dorkbox.util.sync.CountDownLatch(0)
/**
* This is only notified when endpoint.close() is called where EVERYTHING is to be closed.
*/
@Volatile
private var closeLatch = dorkbox.util.sync.CountDownLatch(1)
/**
* Returns the storage used by this endpoint. This is the backing data structure for key/value pairs, and can be a database, file, etc
@ -790,7 +796,7 @@ abstract class EndPoint<CONNECTION : Connection> private constructor(val type: C
/**
* Waits for this endpoint to be closed
* Waits for this endpoint to be fully closed. A disconnect from the network (or remote endpoint) will not signal this to continue.
*/
suspend fun waitForClose(): Boolean {
return waitForClose(0L)