The code might look like this: var q := new queue coroutine produce loop while q is not full create some new items add the items to q yield to consume coroutine consume loop while q is not empty remove some items from q use the items yield to produce The queue is then completely filled or emptied before yielding control to the other coroutine using the yield command.
Koden skulle kunna se ut så här: var q := new queue coroutine produce loop while q is not full create some new items add the items to q yield to consume coroutine consume loop while q is not empty remove some items from q use the items yield to produce Varje korutin gör så mycket den kan innan den överlämnar kontrollen till den andra, med yield-kommandot.