Is a Net::CIDR::Lite object safe to use within a threads::shared environment, given appropriate locking to protect object accesses as 'critical code"?
I need to test single IPs against listed CIDRs (a small (<10) set) from within multiple worker-bee threads. The documentation does not address the issue.
I specificly did not use the term "threadsafe", since that implies internal multi-thread protection. I would be using a shared locking variable to insure single thread access.
-----Update------
I went ahead and started coding a small test program. I found that:
threw an error ofmy $cidrDB : shared; my $cidrLock:shared; $cidrDB = Net::CIDR::Lite->new;
The 'object' is probably too complex a data type to be shared. So my next approach is that I will create the "our $cidrDB" in the main thread; and use:
testing continues....package CIDRDB; .... #code that runs in worker-bee threads my $cidrLock:shared; sub add_cidr { my $arg=shift; { lock $cidrLock; $main::cidrDB->add_any($arg); $main::cidrDB->prep_find(); } }
In reply to Is a Net::CIDR::Lite object sharable within threads by Wiggins
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |