ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/perlmulticore/perlmulticore.pod
(Generate patch)

Comparing perlmulticore/perlmulticore.pod (file contents):
Revision 1.15 by root, Mon Mar 4 06:51:37 2019 UTC vs.
Revision 1.16 by root, Mon Mar 4 15:41:29 2019 UTC

597 597
598=back 598=back
599 599
600Pick your poison. 600Pick your poison.
601 601
602=head2 Case Study: C<DBD::SQLite>
603
604Last not least, while the abovew case studies show some difficult
605examples, let's look at a more typical easy case, L<DBD::SQLite>.
606
607Practically all work is done by calling C<_sqlite_exec> in F<dbdimp.c>, so
608other than copying F<perlmulticore.h> into the source tree and adding
609
610 #include "perlmulticore.h"
611
612to that file, you only need to change the call to C<sqlite3_exec> in
613that function by sandwiching it between C<perlinterp_release> and
614C<perlinterp_acquire>:
615
616 int
617 _sqlite_exec(pTHX_ SV *h, sqlite3 *db, const char *sql)
618 {
619 int rc;
620 char *errmsg;
621
622 perlinterp_release (); // added
623 rc = sqlite3_exec(db, sql, NULL, NULL, &errmsg);
624 perlinterp_acquire (); // added
625 ...
626
627To also catch the database opening phase, the same needs to be done for
628C<_sqlite_open>:
629
630 _sqlite_open(pTHX_ SV *dbh, const char *dbname, sqlite3 **db, int flags, int extended)
631 {
632 int rc;
633 perlinterp_release (); // added
634 if (flags) {
635 rc = sqlite3_open_v2(dbname, db, flags, NULL);
636 } else {
637 rc = sqlite3_open(dbname, db);
638 }
639 perlinterp_acquire (); // added
640 if ( rc != SQLITE_OK ) {
641
642And that is it.
643 602
644=head1 SEE ALSO 603=head1 SEE ALSO
645 604
646This document's canonical web address: L<http://perlmulticore.schmorp.de/> 605This document's canonical web address: L<http://perlmulticore.schmorp.de/>
647 606

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines