Adding Hash's to a Thread::Queue, it is possible? Serialize a Hash and put it in the Queue is an option? How?
#!/opt/coolstack/bin/perl use strict; use threads ('yield', 'stack_size' => 64*4096, 'exit' => 'threads_only', 'stringify'); use Thread::Queue; my $nloaders = 64; #--------------------------------------------------------------- my @thrs_loaders; my $queue = Thread::Queue->new(); for(1..$nloaders){ print "START LOAD $_ \n"; my ($thr) = threads->create(\&load, $_); push @thrs_loaders ,$thr; } $_->join for @thrs_loaders; exit; #--------------------------------------------------------------------- sub load{ my $id = shift; my $tmp; for(1..1e3){ my %rec = ('key_1' => 'val_1', 'key_2' => 'val_2'); $queue->enqueue(\%rec); # This give me an error: Invalid value fo +r shared scalar } print "STOP $id\n"; }
In reply to How to put Hash's on Thread::Queue by gulden
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |