-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Use coroutineScope and async instead of CountDownLatch #940
base: develop
Are you sure you want to change the base?
Conversation
Using deferred to wait for all async calls to end instead of using a CountDownLatch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try This instead
p1.txt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do as we discussed
The CoroutineScope will wait for all Jobs to finish so there is no need for the Deferred.
Do not merge this, I want to test this more to be sure it is working correctly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
storage.consume( | ||
msisdn = consumptionRequest.msisdn, | ||
usedBytes = consumptionRequest.usedBytes, | ||
requestedBytes = consumptionRequest.requestedBytes) { storeResult -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that the coroutine scope will wait til the last argument to storage.consume
- the lambda with storeResult arg is called back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct. I have seen it fail in AT. So this is not working
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I understand what you are talking about
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
storage.consume()
calls it callback in a different CoroutineScope
. A new one is created when we call writeSuspended()
This was not waiting for the callback to complete. Now it use async and scope.
This will help to avoid confusion of while using threads and coroutines together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review my changes
This reverts commit 725192b. The actual patch fails to run `load test Neo4j`
I have reverted the change I made for converting CompletionStage to Deferred. The load test with |
This will help to avoid confusion of while using threads and coroutines together.
That revert made the |
Using deferred to wait for all async calls to end instead of using
a CountDownLatch.