Skip to content
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

Add way to convert CoroutineDispatcher to Scheduler #1923

Closed
wants to merge 76 commits into from

Conversation

recheej
Copy link
Contributor

@recheej recheej commented Apr 19, 2020

Fixes #968 and fixes #548 (duplicates).

@recheej recheej changed the title Rejozil/dispatchertoscheduler Add way to convert CoroutineDispatcher to Scheduler Apr 19, 2020
reactive/kotlinx-coroutines-rx2/src/RxScheduler.kt Outdated Show resolved Hide resolved
reactive/kotlinx-coroutines-rx2/src/RxScheduler.kt Outdated Show resolved Hide resolved
reactive/kotlinx-coroutines-rx2/test/SchedulerTest.kt Outdated Show resolved Hide resolved
reactive/kotlinx-coroutines-rx2/src/RxScheduler.kt Outdated Show resolved Hide resolved
reactive/kotlinx-coroutines-rx2/src/RxScheduler.kt Outdated Show resolved Hide resolved
reactive/kotlinx-coroutines-rx2/src/RxScheduler.kt Outdated Show resolved Hide resolved
@recheej
Copy link
Contributor Author

recheej commented Apr 21, 2020

@elizarov ready for review again. Indeed there were some OOM issues so I simplified the job handling. as per your recommendations.

@recheej recheej requested a review from elizarov April 21, 2020 05:26
@recheej recheej requested a review from elizarov April 21, 2020 16:29
@recheej recheej marked this pull request as draft April 24, 2020 04:35
@recheej recheej marked this pull request as ready for review April 26, 2020 20:10
@recheej recheej requested a review from elizarov April 26, 2020 20:10
@recheej recheej force-pushed the rejozil/dispatchertoscheduler branch from 22351e6 to 556cf91 Compare April 26, 2020 20:11
@recheej
Copy link
Contributor Author

recheej commented Apr 26, 2020

@elizarov I created new API: Job.asDisposable(). What steps should I follow to make sure the api is documented, published, etc?

@recheej recheej force-pushed the rejozil/dispatchertoscheduler branch from 556cf91 to 2d89cbf Compare April 26, 2020 20:23
reactive/kotlinx-coroutines-rx2/src/RxScheduler.kt Outdated Show resolved Hide resolved
reactive/kotlinx-coroutines-rx2/src/RxScheduler.kt Outdated Show resolved Hide resolved
reactive/kotlinx-coroutines-rx2/src/RxScheduler.kt Outdated Show resolved Hide resolved
reactive/kotlinx-coroutines-rx2/src/RxScheduler.kt Outdated Show resolved Hide resolved
reactive/kotlinx-coroutines-rx2/src/RxScheduler.kt Outdated Show resolved Hide resolved
reactive/kotlinx-coroutines-rx2/src/RxScheduler.kt Outdated Show resolved Hide resolved
reactive/kotlinx-coroutines-rx2/src/RxScheduler.kt Outdated Show resolved Hide resolved
reactive/kotlinx-coroutines-rx2/src/RxScheduler.kt Outdated Show resolved Hide resolved
@recheej recheej force-pushed the rejozil/dispatchertoscheduler branch from 32d51ae to 3777437 Compare April 29, 2020 01:13
@recheej
Copy link
Contributor Author

recheej commented Apr 29, 2020

@elizarov ready for review again.

@recheej
Copy link
Contributor Author

recheej commented Apr 30, 2020

Before this gets merged I will squash + rebase

Copy link
Contributor

@zach-klippenstein zach-klippenstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the last update accidentally broke some scheduling logic, and there are still more tests that need to be written.

One general bit of feedback on these tests is that they shouldn't actually cause any real delays. Unit tests should really not actually sleep at all if possible - they should be very fast, and every additional sleep slows down every future PR. The coroutine library has great support for testing with special dispatchers that give you fine-grained control over time, and those tools would be very useful for testing this very time-dependent logic. Here are some links to look at:

reactive/kotlinx-coroutines-rx2/src/RxScheduler.kt Outdated Show resolved Hide resolved
reactive/kotlinx-coroutines-rx2/src/RxScheduler.kt Outdated Show resolved Hide resolved
reactive/kotlinx-coroutines-rx2/src/RxScheduler.kt Outdated Show resolved Hide resolved
reactive/kotlinx-coroutines-rx2/test/SchedulerTest.kt Outdated Show resolved Hide resolved
reactive/kotlinx-coroutines-rx2/test/SchedulerTest.kt Outdated Show resolved Hide resolved
reactive/kotlinx-coroutines-rx2/test/SchedulerTest.kt Outdated Show resolved Hide resolved
@recheej
Copy link
Contributor Author

recheej commented May 5, 2020

@zach-klippenstein @elizarov ready for review.

@recheej recheej force-pushed the rejozil/dispatchertoscheduler branch 4 times, most recently from b8f996f to 91da78f Compare May 7, 2020 01:54
@elizarov
Copy link
Contributor

elizarov commented May 7, 2020

Please, ping me when you're done and its ready for review.

@recheej
Copy link
Contributor Author

recheej commented May 7, 2020

@elizarov this is ready for review

@recheej
Copy link
Contributor Author

recheej commented May 10, 2020

@zach-klippenstein @elizarov ready for review

Copy link
Contributor

@zach-klippenstein zach-klippenstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation mostly looks good, just two things left. I haven't re-reviewed the tests, I'm going to leave those for Roman since he's much more experienced writing tests for this stuff.

reactive/kotlinx-coroutines-rx2/src/RxScheduler.kt Outdated Show resolved Hide resolved
reactive/kotlinx-coroutines-rx2/src/RxScheduler.kt Outdated Show resolved Hide resolved
@recheej recheej force-pushed the rejozil/dispatchertoscheduler branch from d474b59 to 2aab409 Compare December 28, 2020 21:48
@recheej
Copy link
Contributor Author

recheej commented Dec 28, 2020

@elizarov I went ahead and copied the changes over for rx3. let me know what else you think can be done.

@denis-bezrukov
Copy link

Is there a plan to merge this? it seems this pr was ready to merge almost year ago
Would be great to see it as a part of 1.6 😊

@dkhalanskyjb
Copy link
Collaborator

Thanks! We will edit this a bit in #3150 before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants