http://dunkels.com/adam/

protothread 1.4 已經是 2006 年的事了 , 裡面的 sample 非常容易了解 , 

這是一個輕量級的 c library ,  主要是處理 stackless task , 可以試看看 ....

看看裡面的  example-small.c   demo ,   兩個 task 其實都在同一個 stack 空間切換執行 ,

thread 要考慮的 lock , 在 coroutine 不需要 , thread 須考慮 被 OS context switch 出去 ,

coroutine 則可以自行決定哪個時點 yield 出 cpu , 然後回來後又從原處開始往下執行 !! 

 

In stackoverflow about coroutine ....

http://stackoverflow.com/questions/1285714/lightweight-portable-c-fibers-mit-license

 

Edit :

http://probablydance.com/2012/11/18/implementing-coroutines-with-ucontext/

這篇文章有一段文字很有趣 , 關於 boost:coroutine , 他說 :

For example here are all the includes you get merely for including “boost/coroutine/coroutine.hpp”:

Which is more than 600 includes. The preprocessed file of just including the header has almost 75000 lines.

 

超過 600 includes !!!!  真的瘋了 ~~~

 Edit2 :

http://fanf.livejournal.com/105413.html

http://fanf.livejournal.com/105655.html

coroutine nice description and source

 

Edit3 :

http://tia.mat.br/blog/html/2012/09/29/asynchronous_i_o_in_c_with_coroutines.html

這個 open source HTTP server 有很不錯 coroutine sample !!

 

Edit4 :

http://nexus.zteo.com/blog/c-coroutines-no-assembly-bad-pun-required/

 

Edit5:   PTT 也有 人寫 :

http://www.ptt.cc/bbs/C_and_CPP/M.1226626226.A.EA1.html

 

Edit6 :  最後 , 不找了 !!!

https://github.com/cloudwu/coroutine/

arrow
arrow
    全站熱搜

    hedgezzz 發表在 痞客邦 留言(0) 人氣()