If it safe to have blocking operation inside flatMap { … } mapper function?
问题 I'd like to organize a thread barrier: given a single lock object, any thread can obtain it and continue thread's chain further, but any other thread will stay dormant on the same lock object until the first thread finishes and releases the lock. Let's express my intention in code (log() simply prints string in a log): val mutex = Semaphore(1) // number of permits is 1 source .subscribeOn(Schedulers.newThread()) // any unbound scheduler (io, newThread) .flatMap { log("#1") mutex