… | |
… | |
611 | |
611 | |
612 | =item BDB::set_sync_prepare $cb |
612 | =item BDB::set_sync_prepare $cb |
613 | |
613 | |
614 | Sets a callback that is called whenever a request is created without an |
614 | Sets a callback that is called whenever a request is created without an |
615 | explicit callback. It has to return two code references. The first is used |
615 | explicit callback. It has to return two code references. The first is used |
616 | as the request callback, and the second is called to wait until the first |
616 | as the request callback (it should save the return status), and the second |
|
|
617 | is called to wait until the first callback has been called (it must set |
|
|
618 | C<$!> to the return status). |
|
|
619 | |
|
|
620 | This mechanism can be used to include BDB into other event mechanisms, |
|
|
621 | such as L<AnyEvent::BDB> or L<Coro::BDB>. |
|
|
622 | |
617 | callback has been called. The default implementation works like this: |
623 | The default implementation works like this: |
618 | |
624 | |
619 | sub { |
625 | sub { |
620 | my $status; |
626 | my $status; |
621 | ( |
627 | ( |
622 | sub { $status = $! }, |
628 | sub { $status = $! }, |
623 | sub { BDB::poll while !defined $status; $! = $status }, |
629 | sub { BDB::poll while !defined $status; $! = $status }, |
624 | ) |
630 | ) |
625 | } |
631 | } |
|
|
632 | |
|
|
633 | It simply blocks the process till the request has finished and then sets |
|
|
634 | C<$!> to the return value. This means that if you don't use a callback, |
|
|
635 | BDB will simply fall back to synchronous operations. |
626 | |
636 | |
627 | =back |
637 | =back |
628 | |
638 | |
629 | =head3 STATISTICAL INFORMATION |
639 | =head3 STATISTICAL INFORMATION |
630 | |
640 | |