I just discovered that the regex engines variables are threadsafe. Rejoice eh?
my $foo = "bar";
$foo =~/(.)/;
iThread->create(sub { $foo =~/b(.)/; print "$1" })->join;
print "$1";
Corretclty prints ab.
However I found a BUG that is kind of explainable I guess:
my $foo = "bar";
$foo =~/(.)/;
iThread->create(sub { print "$1\n"; })->join;
SEGFAULTS with:
#0 0x8098ab9 in Perl_magic_get ()
#1 0x809803e in Perl_mg_get ()
#2 0x80a1138 in Perl_pp_concat ()
#3 0x80a0b51 in Perl_runops_standard ()
#4 0x8060458 in S_call_body ()
#5 0x805ffba in Perl_call_sv ()
#6 0x40185f6d in ithread_run ()
That is on the todo to document and then fix!
Artur