serebit
12/31/2019, 4:39 PMaltavir
12/31/2019, 4:45 PMDominaezzz
12/31/2019, 4:45 PMaltavir
12/31/2019, 4:46 PMserebit
12/31/2019, 4:47 PMConcurrentHashMap
.Kris Wong
12/31/2019, 4:51 PMserebit
12/31/2019, 4:52 PMKris Wong
12/31/2019, 4:53 PMKris Wong
12/31/2019, 4:54 PMserebit
12/31/2019, 4:56 PMPaul Idstein
12/31/2019, 5:59 PMAny.share()
Kris Wong
12/31/2019, 6:02 PMkpgalligan
12/31/2019, 6:17 PMkpgalligan
12/31/2019, 6:18 PMkpgalligan
12/31/2019, 6:19 PMKris Wong
12/31/2019, 6:20 PMkpgalligan
12/31/2019, 6:21 PMKris Wong
12/31/2019, 6:23 PMkpgalligan
12/31/2019, 6:23 PMkpgalligan
12/31/2019, 6:25 PMkpgalligan
12/31/2019, 6:31 PMkpgalligan
12/31/2019, 6:32 PMclass SharedState: IsolateState<MutableList<String>>({ mutableListOf()}) {
suspend fun pop():String? = withContext(stateDispatcher) {
access { isoList ->
if(isoList.size > 0)
isoList.remove(0)
else
null
}
}
}
kpgalligan
12/31/2019, 6:34 PMwithContext(stateDispatcher)
), then the access
gives the state and you can treat it like any mutable state. Anything that happens in there is thread confined, so other threads won’t cause issues. Using just a concurrent list of some type, the size check might not be valid right after you check it, so you need to also add locks or whatever.kpgalligan
12/31/2019, 6:36 PMErik Christensen
12/31/2019, 11:50 PMConcurrentHashMap
-like. Might play around a little at some point.serebit
12/31/2019, 11:57 PMLulu
01/01/2020, 3:51 PMConcurrentHashMap
approach by implementing a custom HashMap
where locking only happens in the section of the map (or bucket) that is being currently modified? It sounds interesting to me and locking can be implemented using Mutex
to be coroutine-friendlykpgalligan
01/01/2020, 4:24 PMkpgalligan
01/01/2020, 4:27 PM