1. 程式人生 > >yield方式轉移執行權的協程之間不是調用者與被調用者的關系,而是彼此對稱、平等的

yield方式轉移執行權的協程之間不是調用者與被調用者的關系,而是彼此對稱、平等的

sof ron pro and link compute eval direct exceptio

zh.wikipedia.org/wiki/協程

與子例程一樣,協程也是一種程序組件。相對子例程而言,協程更為一般和靈活,但在實踐中使用沒有子例程那樣廣泛。協程源自Simula和Modula-2語言,但也有其他語言支持。協程更適合於用來實現彼此熟悉的程序組件,如合作式多任務,叠代器,無限列表和管道。

en.wikipedia.org/wiki/Coroutine

Coroutines are computer-program components that generalize subroutines for non-preemptive multitasking, by allowing multiple entry points for suspending and resuming execution at certain locations. Coroutines are well-suited for implementing familiar program components such as cooperative tasks, exceptions, event loops, iterators, infinite lists and pipes.

Subroutines are special cases of ... coroutines.

—?Donald Knuth.[3]

yield方式轉移執行權的協程之間不是調用者與被調用者的關系,而是彼此對稱、平等的