As far as I know, FastCGI does not use Perl threads, but processes. Therefore, you must be safe.
Also, if you use Perl and Parse :: RecDescent streams, you will probably never use the same object to analyze different things at the same time. Pseudocode:
use threads;
use Parse::RecDescent;
our $SingletonRD = Parse::RecDescent->new($grammar);
my @threads = map {threads->new(\&thread_loop)} (1..5);
sub thread_loop {
$SingletonRD->parse($text);
}
This is an example where threads are created after a singleton. Here's what happens:
- You create a single object and save it to
$SingletonRD. - You create (in a loop) five threads. When spawns a new thread, perl does
$SingletonRD . . , , , -.
threads:: shared . () . , , Parse:: RecDescent.
PS: Parse:: Yapp , Parse:: Eyapp. , (), Parse:: RecDescent, , .