Ruby勉強会@関西でFiberについて勉強してきた - はこべブログ ♨ã§Perlã§ãGeneratorããã¾ãæ¸ããã¢ã¸ã¥ã¼ã«ããªãããªã¼ã¨ãã¼ãã¦ããã¨ããï¼
perlã§ã¯Coroã§ã»ã¼åãäºãã§ããããã©ã¡ãã«ããCoroã使ãå©ç¹ã¯1å1åãresumeãããã¨ãããªã㦠éåæã«å®è£ ãããã¨ã ã¨æãã®ã§generatoräºã ã¯ã¡ãã£ã¨ç¨éãéãæ°ãããã§ã
http://b.hatena.ne.jp/lestrrat/20090202#bookmark-11922880
ã¨ãããã³ã¡ãããã ãã¾ããï¼id:lestrratãããããã¨ããããã¾ãï¼
Coroã«ã¤ãã¦èª¿ã¹ã¦ã¿ãã¨ããï¼Coro::Introã«ããã¨
The natural application for these is to include a scheduler, resulting in cooperative threads, which is the main use case for Coro today.
ã¨ãã£ã¦ï¼ãã¯ãï¼ã¹ã±ã¸ã¥ã¼ãªã³ã°ãªã©ããããªãï¼ã³ã«ã¼ãã³ããããã¶ãé«æ©è½ãªãã®ã«ãªã£ã¦ããã¿ããã§ãï¼ãã ãï¼
Coro started as a simple module that implemented a specific form of first class continuations called Coroutines.
...
This is nowadays known as a Coro::State.
ã¨ããããã«ï¼ãã¨ãã¨æã£ã¦ããç´ç²ãªã³ã«ã¼ãã³ã®æ©è½ã¯Coro::Stateã¨ããã¢ã¸ã¥ã¼ã«ã§å®ç¾ã§ããããã§ãï¼
Coro::Stateã«ã¯ã³ã«ã¼ãã³ããããããtransferã¨ããã¡ã½ãããç¨æããã¦ããã®ã§ããï¼ãã®ã¡ã½ããã¯Ruby1.9ã®Fiberã®yieldã®ããã«å¤ãè¿ããã¨ãã§ãã¾ããï¼ã³ã«ã¼ãã³åãæ¿ãæã®å¤ã¯å¥ã«è¨é²ãã¦ããå¿
è¦ãããã¾ãï¼ãã®ãããã注æãã¦ï¼ä»¥ä¸ã®ããã«Generatorãå®è£
ãã¦ã¿ã¾ããï¼
56803’s gists · GitHub
yieldã§å¤ãè¿ããªãã¶ãä¸ã¤ä½è¨ã«ã¯ãã¼ã¸ã£ãå¿
è¦ã«ãªã£ã¦ããã®ã§ï¼ã¡ãã£ã¨ãã©ãã³ã¼ãã«ãªã£ã¦ã¾ãï¼ãããï¼ããã¯Perlã¨ãããCPANã¨ãããï¼ãã®ã³ã¼ãããã¾ãã©ããã³ã°ãã¦ãããã¢ã¸ã¥ã¼ã«ã§ããCoro::Generatorãããã¾ããï¼
Coro::Generatorãå©ç¨ããã¨ï¼åãã³ã¼ãã以ä¸ã®ããã«æ¸ãã¾ãï¼
coro_generator.pl · GitHub
ããã¶ãã³ã¼ãã®æå³ããããããããªãã¾ããï¼
ã¨ããããã§ï¼Rubyã®Fiberã¨åããããªãã¨ãããããã°ï¼Perlã§ã¯Coroã使ãã£ã¦ãã¨ã§ããï¼Coroèªä½ã¯ã³ã«ã¼ãã³ã®å®ç¾ä»¥å¤ã«ä¸¦åå¦çãç°¡åã«æ¸ããä»çµã¿ããããããã£ã¦ä¾¿å©ãããªã®ã§ï¼ãã¾ã使ããã¨ãã£ãããã§ããï¼