--- BDB/BDB.pm 2008/09/25 13:30:14 1.49 +++ BDB/BDB.pm 2008/09/25 22:09:02 1.50 @@ -705,7 +705,7 @@ C is mainly useful in simple scripts (with low values) or as a stop gap to shield against fatal memory overflow (with large values). -=item BDB::set_sync_prepare $cb +=item $old_cb = BDB::set_sync_prepare $cb Sets a callback that is called whenever a request is created without an explicit callback. It has to return two code references. The first is used @@ -714,9 +714,10 @@ C<$!> to the return status). This mechanism can be used to include BDB into other event mechanisms, -such as L or L. +such as L. -The default implementation works like this: +To allow other, callback-based, events to be executed while callback-less +ones are run, you could use this sync prepare function: sub { my $status; @@ -726,9 +727,13 @@ ) } -It simply blocks the process till the request has finished and then sets -C<$!> to the return value. This means that if you don't use a callback, -BDB will simply fall back to synchronous operations. +It works by polling for results till the request has finished and then +sets C<$!> to the return value. This means that if you don't use a +callback, BDB would simply fall back to synchronous operations. + +By default, or if the sync prepare function is set to C, is to +execute callback-less BDB requests in the foreground thread, setting C<$!> +to the return value, without polling for other events. =back @@ -760,18 +765,7 @@ =cut -set_sync_prepare { - my $status; - ( - sub { - $status = $!; - }, - sub { - BDB::poll while !defined $status; - $! = $status; - }, - ) -}; +set_sync_prepare (undef); min_parallel 8;