I am learning to write async programs. Need guidance from where to learn.
Example use case:
- Counter increasing 1 every second in the background within (0-9)
- Another counter picking random values between 4 and 9 at an interval of 1.5 seconds
- Spawn 4 independent processes (preferably low cost), take the counter values as 1st and 2nd digits and output the ASCII characters sequentially. 1st thread should retain and update values every 1 second, 2nd thread should retain and update values every 2 seconds, and so on.
e.g.: If the 1st counter value is 5 and the 2nd counter value is 6, then the output should be A. Similarly, there should be other characters and shown as output like A4Ob
Is this possible? If yes, require pseudocode for the same. One without ordering the processes, and another with ordering (i.e. 1st process output should be shown 1st)
Also how to sync multiple async functions? i.e. can one async function use another a normal sync function? If yes, how to convert the output of the normal sync function to a future?
I am willing to learn and invest time into this. Constructive ideas will suffice