https://kotlinlang.org logo
Title
f

fstn

10/24/2017, 8:26 PM
Hi guys, I have 1 mutualized set of data that will be query by multiple thread, the idea is to query this set and return and remove it from the set For example the set can contains ResquestObjects (date,level,subject) I need to query to find the last request with subject = A and immediately remove it in java I would have used synchronized for that is there a better solution? I use Kotlin, RxJava and Vertx
:stackoverflow: 1
d

dave08

10/25/2017, 2:48 AM
I personally also started with vertx and rxjava, but i then switched to vertx with coroutines, which looks more natural after the steep learning curve. Vertx 3.5 just came out with support for it, and what you would want is a coroutines actor with a set inside, and use remove ( which i think returns the removed element)
f

fstn

10/25/2017, 3:29 AM
thanks, using coroutine, I will only have one call at the time?
d

dave08

10/25/2017, 4:55 AM
Yes, thats the point of an actor, to manage modiying mutable state from many threads... you can see the getting started w corouutines guide in kotlinx for an example
👍 1