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