How can I enforce only 1 execution of Observable/S...
# rx
u
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
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
why would need that? transactions are synchronized arent they?
t
was just the best config for perf. I think because the synchronization is expensive so fewer large transaction ended up being elss overhead
u
Not sure how is it more expensive, than enqueueing actions in a single threaded scheduler
same thing
only one writes, all else waits
t
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
@ursus if you have a bunch of observables then maybe concatMap?
u
no sorry this is more like a queue, I dont know everything at subscribe time
b
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
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)