… | |
… | |
65 | use base 'Exporter'; |
65 | use base 'Exporter'; |
66 | |
66 | |
67 | BEGIN { |
67 | BEGIN { |
68 | our $VERSION = '0.1'; |
68 | our $VERSION = '0.1'; |
69 | |
69 | |
70 | our @BDB_REQ = qw(); |
70 | our @BDB_REQ = qw( |
|
|
71 | db_env_create db_env_open db_env_close |
|
|
72 | db_create db_open db_close db_compact db_sync db_put db_get db_pget |
|
|
73 | db_txn_commit db_txn_abort |
|
|
74 | ); |
|
|
75 | our @EXPORT = (@BDB_REQ, qw(dbreq_pri dbreq_nice)); |
71 | our @EXPORT_OK = qw(poll_fileno poll_cb poll_wait flush |
76 | our @EXPORT_OK = qw(poll_fileno poll_cb poll_wait flush |
72 | min_parallel max_parallel max_idle |
77 | min_parallel max_parallel max_idle |
73 | nreqs nready npending nthreads |
78 | nreqs nready npending nthreads |
74 | max_poll_time max_poll_reqs); |
79 | max_poll_time max_poll_reqs); |
75 | |
80 | |
… | |
… | |
236 | |
241 | |
237 | You can still queue as many requests as you want. Therefore, |
242 | You can still queue as many requests as you want. Therefore, |
238 | C<max_oustsanding> is mainly useful in simple scripts (with low values) or |
243 | C<max_oustsanding> is mainly useful in simple scripts (with low values) or |
239 | as a stop gap to shield against fatal memory overflow (with large values). |
244 | as a stop gap to shield against fatal memory overflow (with large values). |
240 | |
245 | |
|
|
246 | =item BDB::set_sync_prepare $cb |
|
|
247 | |
|
|
248 | Sets a callback that is called whenever a request is created without an |
|
|
249 | explicit callback. It has to return two code references. The first is used |
|
|
250 | as the request callback, and the second is called to wait until the first |
|
|
251 | callback has been called. The default implementation works like this: |
|
|
252 | |
|
|
253 | sub { |
|
|
254 | my $status; |
|
|
255 | ( |
|
|
256 | sub { $status = $! }, |
|
|
257 | sub { BDB::poll while !defined $status; $! = $status }, |
|
|
258 | ) |
|
|
259 | } |
|
|
260 | |
|
|
261 | =back |
|
|
262 | |
241 | =head3 STATISTICAL INFORMATION |
263 | =head3 STATISTICAL INFORMATION |
|
|
264 | |
|
|
265 | =over 4 |
242 | |
266 | |
243 | =item BDB::nreqs |
267 | =item BDB::nreqs |
244 | |
268 | |
245 | Returns the number of requests currently in the ready, execute or pending |
269 | Returns the number of requests currently in the ready, execute or pending |
246 | states (i.e. for which their callback has not been invoked yet). |
270 | states (i.e. for which their callback has not been invoked yet). |
… | |
… | |
261 | but not yet processed by poll_cb). |
285 | but not yet processed by poll_cb). |
262 | |
286 | |
263 | =back |
287 | =back |
264 | |
288 | |
265 | =cut |
289 | =cut |
|
|
290 | |
|
|
291 | set_sync_prepare { |
|
|
292 | my $status; |
|
|
293 | ( |
|
|
294 | sub { |
|
|
295 | $status = $!; |
|
|
296 | }, |
|
|
297 | sub { |
|
|
298 | BDB::poll while !defined $status; |
|
|
299 | $! = $status; |
|
|
300 | }, |
|
|
301 | ) |
|
|
302 | }; |
266 | |
303 | |
267 | min_parallel 8; |
304 | min_parallel 8; |
268 | |
305 | |
269 | END { flush } |
306 | END { flush } |
270 | |
307 | |