4 use threads
; # ('exit' => 'threads_only');
5 use BerkeleyDB
; #man 3pm BerkeleyDB
9 our $dbenv = BerkeleyDB
::Env
->new(
11 -Flags
=> DB_CREATE
|DB_INIT_CDB
|DB_INIT_MPOOL
12 ) or die("cannot open environment: $BerkeleyDB::Error\n");
14 our $dbq = BerkeleyDB
::Queue
->new(
15 -Filename
=> 'urls.queue' ,
19 ) or die("cannot open queue: $BerkeleyDB::Error\n");
21 for(my $i=0;$i<10;$i++) { $dbq->db_put($i, 'toto'); }
25 for(my $i=0; $i<$threads; $i++) {
26 my $thr = threads
->create(sub {
27 print("[*] Worker #$i running!\n");
30 my $cursor = $dbq->db_cursor() ;
31 while ($cursor->c_get($key, $val, DB_NEXT
) == 0) {
32 #print "$key -> $val\n"
34 if($val) { print("[$i] $key = $val\n"); }
36 #$dbq->db_get($key, $val, DB_CONSUME);
37 print("[*] Worker #$i stopped!\n");
This page took 1.499505 seconds and 4 git commands to generate.