in reply to Re^4: Shared variables between threads
in thread Shared variables between threads
You will need to threads::shared::share it before you'll be able to assign it to a shared variable.
#! perl -slw use strict; use threads; use threads::shared; print "threads: $threads::VERSION threads::shared:$threads::shared::VE +RSION"; { my $scalar = 0xdeadbeef; my $blessed = bless \$scalar, 'main'; print 'Scalar: ', $blessed; my $shared :shared = &share( $blessed ); print 'Scalar: ', $shared; } __END__ C:\test>t-blessed.pl threads: 1.67 threads::shared:1.14 Scalar: main=SCALAR(0x1824624) Scalar: main=SCALAR(0x1824624)
For your case that should look something like:
my $capobj:shared; $capobj = &share( Net::Pcap::open_live($dev,1024,0,0,\$err) );
Or just
my $capobj:shared = &share( Net::Pcap::open_live($dev,1024,0,0,\$err) +);
The ampasand on &share() is necessary to defeat the prototype.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Shared variables between threads
by Saladino (Beadle) on Nov 05, 2007 at 11:19 UTC | |
by BrowserUk (Patriarch) on Nov 05, 2007 at 12:05 UTC | |
by Saladino (Beadle) on Nov 05, 2007 at 12:19 UTC | |
by BrowserUk (Patriarch) on Nov 05, 2007 at 12:51 UTC | |
by Saladino (Beadle) on Nov 05, 2007 at 13:49 UTC |