=encoding euc-jp =head1 名前 Thread::Queue - スレッドセーフなキュー(待ち行列) =head1 概要 use Thread::Queue; my $q = new Thread::Queue; $q->enqueue("foo", "bar"); my $foo = $q->dequeue; # "bar"はまだキューの中にある。 my $foo = $q->dequeue_nb; # "bar"を返す。キューが空ならundefを返す。 my $left = $q->pending; # キューの中に存在する要素の数を返す。 =head1 説明 A queue, as implemented by C is a thread-safe data structure much like a list. Any number of threads can safely add elements to the end of the list, or remove elements from the head of the list. (Queues don't permit adding or removing elements from the middle of the list). Cによって実装されるキュー(待ち行列)はリストによくにた スレッドセーフなデータ構造である。任意の数のスレッドが安全にリストの 最後に要素を付け加えたり、先頭から要素を取り除いたりすることができる (リストの中間部に対して加えたり取り除いたりするとこは出来ない)。 =head1 関数とメソッド =over 8 =item new The C function creates a new empty queue. C関数は新規の空のキューを生成する。 =item enqueue LIST The C method adds a list of scalars on to the end of the queue. The queue will grow as needed to accommodate the list. Cメソッドはキューの最後にスカラーのリストを付け加える。 リストに応じてキューは成長する。 =item dequeue The C method removes a scalar from the head of the queue and returns it. If the queue is currently empty, C will block the thread until another thread Cs a scalar. Cメソッドはキューの先頭からスカラーを取り除き、それを返す。 キューが空のとき、Cは他のスレッドがスカラーをCする までブロックする。 =item dequeue_nb The C method, like the C method, removes a scalar from the head of the queue and returns it. Unlike C, though, C won't block if the queue is empty, instead returning C. CメソッドはCメソッドのように、キューの先頭から スカラーを取り除く。だがCと違って、Cはキューが 空でもブロックしない。代わりにCを返す。 =item pending The C method returns the number of items still in the queue. Cメソッドは、まだキューに入っている要素の数を返す。 =back =head1 SEE ALSO L, L