ostelco-core icon indicating copy to clipboard operation
ostelco-core copied to clipboard

[WIP] Use coroutineScope and async instead of CountDownLatch

Open mpeterss opened this issue 5 years ago • 4 comments

Using deferred to wait for all async calls to end instead of using a CountDownLatch.

mpeterss avatar Nov 14 '19 13:11 mpeterss

Do not merge this, I want to test this more to be sure it is working correctly

mpeterss avatar Nov 15 '19 10:11 mpeterss

DO NOT MERGE THIS. The Kotlin Coroutine might not work.

The scope will work when the child coroutines are async using suspend. In that case, the callback is handled as a continuation.

But in this case, the callback is an execution of the lambda function which is passed as the last parameter.

So, the parent coroutine scope will be blocked till all the coroutines in it are completed, but they get completed immediately. The scope will not be blocked until all the callbacks are executed.

Are you talking about the bimap lamda? I don't see any asynchronous calls than the async in consumeRequestHandler . If the whole loop (request.msccList.forEach) runs synchronously, the asyncs methods will be called before the loop is finished. In such cases the async calls are part of the coroutineScope

prasanthu avatar Nov 15 '19 12:11 prasanthu

I have reverted the change I made for converting CompletionStage to Deferred. The load test with 10_000 requests failed with this change. The max I could do was 500

prasanthu avatar Nov 18 '19 17:11 prasanthu

That revert made the creditControlRequestInitTerminateNoCredit fail. So bringing the change back. We need to sit together and understand this

prasanthu avatar Nov 18 '19 17:11 prasanthu