https://kotlinlang.org logo
#rx
Title
# rx
u

ursus

04/07/2020, 4:00 PM
How can I enforce only 1 execution of Observable/Single at the time? I know about maxConcurrency of flatMap, but that requires that flatMap to be on a top level in the chain If its inside say switchMap, then its all gone Semaphores maybe?
t

trevjones

04/07/2020, 4:06 PM
if you can control the scheduler cleanly you could try the single scheduler? i've done similar to ensure only one thread owns DB writes (android sqlite with WAL enabled)
u

ursus

04/09/2020, 1:12 AM
why would need that? transactions are synchronized arent they?
t

trevjones

04/09/2020, 2:04 AM
was just the best config for perf. I think because the synchronization is expensive so fewer large transaction ended up being elss overhead
u

ursus

04/09/2020, 3:23 AM
Not sure how is it more expensive, than enqueueing actions in a single threaded scheduler
same thing
only one writes, all else waits
t

trevjones

04/09/2020, 3:25 AM
only if you make the others wait. the write thread would only do anything once a queue depth or time was reached. it was an odd system for sure, but for sure was faster to batch the way it was
dangerous in a sense but the data model had a recovery mechanism to it
b

Bruno_

04/09/2020, 11:48 AM
@ursus if you have a bunch of observables then maybe concatMap?
u

ursus

04/09/2020, 2:53 PM
no sorry this is more like a queue, I dont know everything at subscribe time
b

Bruno_

04/09/2020, 5:45 PM
wdym? not sure how it looks like in the code, but based on what you've sent in the first msg then it should do the job
u

ursus

04/09/2020, 6:13 PM
flatMap concurreny = 1 makes it into a queue; its an ongoing thing, you can pop stuff into it, I dont know everybody who will be subscribed ahead of time, like you need to concat(obs1, obs2, obs3)
4 Views