The title may be a bit vague. This is what I mean:
Say I have two ways of getting input to my program. The first is via the keyboard, using the function getLine
which blocks until a line is read. The other is, say, via a TChan
, where using readTChan chan
will also result in a block until a value is present in the channel, whereupon it will be read.
What I want to accomplish is being able to wait for both values, using a single thread and not allowing my CPU to jump to 100%. The moment one of the two values is available, it is fetched and the program resumes. (Say, using Either
to notify which of the two values was received.)
Is this possible?
Thank you very much!