Re: optimize log parsing
- From: "it_says_BALLS_on_your forehead" <simon.chao@xxxxxxx>
- Date: 5 Oct 2005 08:15:51 -0700
>
> Extremely easy with threads. Here's a complete example of a program that
> spawns off a number of threads where each thread pulls data from a
> global queue until it is empty:
i'm running Perl 5.6, are threads and threads::shared available/stable
in this version?
>
> #!/usr/bin/perl -w
>
> use strict;
>
> use threads;
> use threads::shared;
>
> use constant NUM_THREADS => 10;
>
> # shared queue visible to every thread
> my @queue : shared = 1 .. 30;
>
> # create threads
> my @threads;
> push @threads, threads->new("run") for 1 .. NUM_THREADS;
>
> # wait for all threads to finish
> $_->join for @threads;
>
> # code executed by each thread
> sub run {
> while (defined(my $element = pop @queue)) {
> printf "thread %i: working with %i\n", threads->tid, $element;
^ what is this?
> # make runtime vary a little for
> # demonstration purpose
> select undef, undef, undef, rand;
> }
> }
>
>
.
- Follow-Ups:
- Re: optimize log parsing
- From: Tassilo v. Parseval
- Re: optimize log parsing
- From: Paul Lalli
- Re: optimize log parsing
- References:
- optimize log parsing
- From: it_says_BALLS_on_your forehead
- Re: optimize log parsing
- From: it_says_BALLS_on_your forehead
- Re: optimize log parsing
- From: Tassilo v. Parseval
- optimize log parsing
- Prev by Date: Re: Perl's umask equivalent command
- Next by Date: Re: Sorting a nested array (table) (alphabetically)
- Previous by thread: Re: optimize log parsing
- Next by thread: Re: optimize log parsing
- Index(es):
Relevant Pages
|