I have these jobs below:
- Inflating a complex calendar view async
- Downloading events A
- Downloading events B
- Adding calendar view to it's parent
- Adding A events to the calendar
- Adding B events to the calendar
I want
- 1, 2, 3 have to start async,
- 4 has to wait for 1
- 5 has to wait for 2 and 4
- 6 has to wait for 3 and 4
- 6 and 5 should not be dependent to each other, can run at different times.
- 4 is only dependent to 1, so it can run before 2 or 3 is finished.
I've tried async await but it makes them finish at the same time (as expected). I think this example might be a good way to learn parallel programming concepts, like semaphores mutex or spin locks. But it's too complicated for me to understand.
How should I implement these with using Kotlin coroutines?