Thread-Detach-0.01 > Thread::Detach

名前

Thread::Detach - Windows上での壊れたthreads->detachの修正

概要

    use Thread::Detach ();   # 修正の適用

解説

                  *** A note of CAUTION ***

 This module only functions on Perl versions 5.8.0 and later.
 And then only when threads are enabled with -Dusethreads.  It
 is of no use with any version of Perl before 5.8.0 or without
 threads enabled.

                  *************************

                  *** 注   意   書   き ***

 このモジュールは、Perlのバージョン5.8.0以降で、かつ、-Dusethreads
 オプションでスレッドが有効になっている場合にのみ機能する。5.8.0以前、
 あるいはスレッドが有効になっていない場合は、使うことができない。

                  *************************

Perl versions before 5.8.4 don't support the "detach" method of the threads module on Windows!. This module provides a temporary fix for this problem if it is running under Windows and with a version of Perl that has the problem. In any other situation, this module does nothing.

Perlのバージョン5.8.4より前では、Windows上でthreadsモジュールの"detach" メソッドがサポートされていない! このモジュールは、Windows上で実行されて、 かつ、その問題を抱えたPerlのバージョンである場合に、暫定的な修正を提供する。 それ以外の状況では、このモジュールは何もしない

操作の理論

All of this happens on Windows only and if the version of the Perl executor is known to have the problem.

これは全てWindows上でのみ発生し、かつ、Perl実行ファイルのバージョンが その問題を抱えているものと知られている場合である。

This module replaces the standard threads-detach> method with another subroutine that just sets an internal flag to mark the thread as "detached".

このモジュールは標準的なthreads-detach>メソッドを別のサブルーチンで 置き換える。このルーチンは単に内部フラグをセットして、そのスレッドを "detached"として印付ける。

Futhermore it uses Thread::Exit to register a subroutine that is executed after each thread is finished executing: this subroutine marks the thread as "done" if the thread was marked as "detached" earlier.

さらに加えて、Thread::Exitを使って、各スレッドが実行処理を終了した後に 実行されるサブルーチンを登録する:このサブルーチンは、もしそのスレッドが 既に"detached"の印がつけられている場合に、"done"として印付ける。

Lastly, it uses Thread::Exit to register a subroutine that is executed at the beginning of each thread: this subroutine reaps all the threads that were marked "done", hence providing the necessary cleanup.

最後に、Thread::Exitを使って各スレッドが始まるときに実行される サブルーチンを登録する:このサブルーチンは"done"の印がつけられたスレッドを 全て刈り取る。これにより必要なクリーンアップが提供される。

必要なモジュール

 Thread::Exit (0.08)

TODO

Maybe the reliance on Thread::Exit should be replaced by some more direct magic. Using Thread::Exit made this module all the more simple, though.

Thread::Exitの信頼性は、より直接的な方法によって置き換えられるべきであろう。 しかし、Thread::Exitの使用により、このモジュールはよりシンプルになった。

Examples should be added.

例の追加。

作者

Elizabeth Mattijsen, <liz@dijkmat.nl>.

Please report bugs to <perlbugs@dijkmat.nl>.

著作権

Copyright (c) 2004 Elizabeth Mattijsen <liz@dijkmat.nl>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

参照

threads, Thread::Exit.