ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent-BDB/BDB.pm
Revision: 1.1
Committed: Sat May 10 20:22:29 2008 UTC (16 years ago) by root
Branch: MAIN
CVS Tags: rel-1_0
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 =head1 NAME
2    
3     AnyEvent::BDB - truly asynchronous berkeley db access
4    
5     =head1 SYNOPSIS
6    
7     use AnyEvent::BDB;
8     use BDB;
9    
10     # can now use any of the requests your BDB module supports
11     # as long as you use an event loop supported by AnyEvent.
12    
13     =head1 DESCRIPTION
14    
15     This module is an L<AnyEvent> user, you need to make sure that you use and
16     run a supported event loop.
17    
18     Loading this module will install the necessary magic to seamlessly
19     integrate L<BDB> into L<AnyEvent>, i.e. you no longer need to concern
20     yourself with calling C<BDB::poll_cb> or any of that stuff (you still
21     can, but this module will do it in case you don't).
22    
23     The AnyEvent watcher can be disabled by executing C<undef
24     $AnyEvent::BDB::WATCHER>. Please notify the author of when and why you
25     think this was necessary.
26    
27     =cut
28    
29     package AnyEvent::BDB;
30    
31     use strict;
32     no warnings;
33    
34     use AnyEvent ();
35     use BDB ();
36    
37     use base Exporter::;
38    
39     our $VERSION = '1.0';
40     our $WATCHER;
41    
42     $WATCHER = AnyEvent::post_detect {
43     if ($AnyEvent::MODEL eq "AnyEvent::Impl::EV") {
44     $WATCHER = EV::io (BDB::poll_fileno, &EV::READ, \&BDB::poll_cb);
45     } else {
46     our $FH; open $FH, "<&=" . BDB::poll_fileno;
47     $WATCHER = AnyEvent->io (fh => $FH, poll => 'r', cb => \&BDB::poll_cb);
48     }
49     };
50    
51     BDB::_on_next_submit \&AnyEvent::detect;
52    
53     =head1 SEE ALSO
54    
55     L<AnyEvent>, L<Coro::BDB> (for a more natural syntax).
56    
57     =head1 AUTHOR
58    
59     Marc Lehmann <schmorp@schmorp.de>
60     http://home.schmorp.de/
61    
62     =cut
63    
64     1
65