タグ

コルーチンに関するkorinのブックマーク (3)

  • Perlで学ぶコルーチン

    8. say quot;startquot;; sub say_hello { say_hello(10); my $n = shift; for (1..$n) { say 'hello'; } return; } say quot;endquot;; 10. my $c = Fiber>new( $c‐>resume; sub{ say 'hello!'; Fiber‐>yield; say 'happy'; $c‐>resume; say 'perl'; Fiber‐>yield; say 'coding'; $c‐>resume; say 'world!'; } ); 11. my $c = Fiber>new( $c‐>resume; sub{ say 'hello!'; Fiber‐>yield; say 'happy'; hello happy $c‐>resume; say

    Perlで学ぶコルーチン
  • Duff's device - Wikipedia

    Duff's Device(ダフスデバイス)とは、C言語での可変長の連続的コピーをループ展開により最適化実装するときに直面する端数の問題を解決するための手法である。 C言語のswitch-case文が持つフォールスルーを利用して、アセンブリ言語で行われる技巧をC言語で実現している。1983年11月、ルーカスフィルムで働いていたトム・ダフが発見した。 背景問題[編集] ループ展開は、ループのための分岐回数を減らす技法である。指定されるループ回数が不明な場合、ループ展開すると回数が合わない場合が出てくるので、ループの途中にジャンプすることで調整する。例えば、8回ぶんのループを展開した場合、指定されたループ回数が8で割り切れないなら、その回数を8で割った剰余のぶんだけ処理を実行する位置にジャンプさせる。 ダフはそのような最適化を検討していてCでの技法を発見した。 来のバージョン[編集] 連続コ

    korin
    korin 2009/01/02
    コルーチン等に応用されている
  • Coroutine - Wikipedia

    This article's use of external links may not follow Wikipedia's policies or guidelines. Please improve this article by removing excessive or inappropriate external links, and converting useful links where appropriate into footnote references. (April 2024) (Learn how and when to remove this message) Coroutines are computer program components that allow execution to be suspended and resumed, general

  • 1