Skip to content

Instantly share code, notes, and snippets.

@niner
Created September 20, 2019 11:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niner/d2dee661dbaa0a5c0f49c0e7262898ee to your computer and use it in GitHub Desktop.
Save niner/d2dee661dbaa0a5c0f49c0e7262898ee to your computer and use it in GitHub Desktop.
use Inline::Perl5;
my $gil = Lock.new;
sub p5() {
my role Perl5Interpreter {
has $.p5 = Inline::Perl5.new;
has $.gil = $gil;
}
my $thread = $*THREAD;
unless $thread.does(Perl5Interpreter) {
$gil.protect: {
$thread does Perl5Interpreter;
$thread.p5.use('Atikon::DB::Timemngt');
$thread.p5.use('DBD::Pg');
$thread.p5.use('DBIx::Class::Storage::DBI');
}
}
$thread.p5
}
await (^30).map: {
start {
say $*THREAD.id ~ ' ' ~ p5.Str;
my $schema = p5.invoke('Atikon::DB::Timemngt', 'connect', 'dbi:Pg:database=timemngt');
$schema.resultset('Customer').count.say;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment