Reverse integrate Malcolm's chanes into local
[p5sagit/p5-mst-13.2.git] / ext / Thread / Thread / Queue.pm
CommitLineData
d21067e0 1package Thread::Queue;
2use Thread qw(cond_wait cond_broadcast);
3
4sub new {
5 my $class = shift;
6 return bless [@_], $class;
7}
8
9sub dequeue {
10 use attrs qw(locked method);
11 my $q = shift;
12 cond_wait $q until @$q;
13 return shift @$q;
14}
15
16sub enqueue {
17 use attrs qw(locked method);
18 my $q = shift;
19 push(@$q, @_) and cond_broadcast $q;
20}
21
221;