… | |
… | |
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_open db_env_close db_env_txn_checkpoint db_env_lock_detect |
|
|
72 | db_env_memp_sync db_env_memp_trickle |
|
|
73 | db_open db_close db_compact db_sync db_put db_get db_pget db_del db_key_range |
|
|
74 | db_txn_commit db_txn_abort |
|
|
75 | db_c_close db_c_count db_c_put db_c_get db_c_pget db_c_del |
|
|
76 | db_sequence_open db_sequence_close |
|
|
77 | db_sequence_get db_sequence_remove |
|
|
78 | ); |
|
|
79 | our @EXPORT = (@BDB_REQ, qw(dbreq_pri dbreq_nice db_env_create db_create)); |
|
|
80 | our @EXPORT_OK = qw( |
71 | our @EXPORT_OK = qw(poll_fileno poll_cb poll_wait flush |
81 | poll_fileno poll_cb poll_wait flush |
72 | min_parallel max_parallel max_idle |
82 | min_parallel max_parallel max_idle |
73 | nreqs nready npending nthreads |
83 | nreqs nready npending nthreads |
74 | max_poll_time max_poll_reqs); |
84 | max_poll_time max_poll_reqs |
|
|
85 | ); |
75 | |
86 | |
76 | require XSLoader; |
87 | require XSLoader; |
77 | XSLoader::load ("BDB", $VERSION); |
88 | XSLoader::load ("BDB", $VERSION); |
78 | } |
89 | } |
79 | |
90 | |
… | |
… | |
236 | |
247 | |
237 | You can still queue as many requests as you want. Therefore, |
248 | 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 |
249 | 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). |
250 | as a stop gap to shield against fatal memory overflow (with large values). |
240 | |
251 | |
|
|
252 | =item BDB::set_sync_prepare $cb |
|
|
253 | |
|
|
254 | Sets a callback that is called whenever a request is created without an |
|
|
255 | explicit callback. It has to return two code references. The first is used |
|
|
256 | as the request callback, and the second is called to wait until the first |
|
|
257 | callback has been called. The default implementation works like this: |
|
|
258 | |
|
|
259 | sub { |
|
|
260 | my $status; |
|
|
261 | ( |
|
|
262 | sub { $status = $! }, |
|
|
263 | sub { BDB::poll while !defined $status; $! = $status }, |
|
|
264 | ) |
|
|
265 | } |
|
|
266 | |
|
|
267 | =back |
|
|
268 | |
241 | =head3 STATISTICAL INFORMATION |
269 | =head3 STATISTICAL INFORMATION |
|
|
270 | |
|
|
271 | =over 4 |
242 | |
272 | |
243 | =item BDB::nreqs |
273 | =item BDB::nreqs |
244 | |
274 | |
245 | Returns the number of requests currently in the ready, execute or pending |
275 | 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). |
276 | states (i.e. for which their callback has not been invoked yet). |
… | |
… | |
261 | but not yet processed by poll_cb). |
291 | but not yet processed by poll_cb). |
262 | |
292 | |
263 | =back |
293 | =back |
264 | |
294 | |
265 | =cut |
295 | =cut |
|
|
296 | |
|
|
297 | set_sync_prepare { |
|
|
298 | my $status; |
|
|
299 | ( |
|
|
300 | sub { |
|
|
301 | $status = $!; |
|
|
302 | }, |
|
|
303 | sub { |
|
|
304 | BDB::poll while !defined $status; |
|
|
305 | $! = $status; |
|
|
306 | }, |
|
|
307 | ) |
|
|
308 | }; |
266 | |
309 | |
267 | min_parallel 8; |
310 | min_parallel 8; |
268 | |
311 | |
269 | END { flush } |
312 | END { flush } |
270 | |
313 | |