# Client class sub send { my ($self, $msg) = @_; $self->{work_queue}->enqueue($msg); } sub worker { my ($self) = @_; my $q = $self->{work_queue}; for (;;) { my $msg = $q->dequeue(); ... send $msg ... } }