Synchronous concurrency: Difference between revisions

Content added Content deleted
Line 1,357: Line 1,357:


Oforth implements concurrency with tasks and communication between tasks using channels. Here, we create 2 channels (one for print, one to retrieve the number of lines).
Oforth implements concurrency with tasks and communication between tasks using channels. Here, we create 2 channels (one for print, one to retrieve the number of lines).

When the file has been read and send to channel chPrint, this channel is closed. All tasks waiting for an object in this channel are released and receive null. Then printing task returns number of printed lines into chCount channel for the main task.


<lang Oforth>func: printing(chPrint, chCount)
<lang Oforth>func: printing(chPrint, chCount)