Use forValidRefs in field synchronizer
This commit is contained in:
parent
82389a5e72
commit
5efe3a2e35
@ -369,17 +369,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa
|
|||||||
nextEndpointsCleanup = secondTime + 60
|
nextEndpointsCleanup = secondTime + 60
|
||||||
|
|
||||||
synchronized(endpoints) {
|
synchronized(endpoints) {
|
||||||
val iterator = endpoints.listIterator()
|
endpoints.forValidRefs { execute.invoke(it) }
|
||||||
|
|
||||||
for (value in iterator) {
|
|
||||||
val endpoint = value.get()
|
|
||||||
|
|
||||||
if (endpoint == null) {
|
|
||||||
iterator.remove()
|
|
||||||
} else {
|
|
||||||
execute.invoke(endpoint)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (endpoints.size < endpointsMaxCapacity / 2) {
|
if (endpoints.size < endpointsMaxCapacity / 2) {
|
||||||
endpoints.trimToSize()
|
endpoints.trimToSize()
|
||||||
|
Loading…
Reference in New Issue
Block a user