|
|
1 | =head1 NAME |
|
|
2 | |
|
|
3 | AnyEvent::Impl::Glib - AnyEvent adaptor for Glib |
|
|
4 | |
|
|
5 | =head1 SYNOPSIS |
|
|
6 | |
|
|
7 | use AnyEvent; |
|
|
8 | use Glib; |
|
|
9 | |
|
|
10 | # this module gets loaded automatically as required |
|
|
11 | |
|
|
12 | =head1 DESCRIPTION |
|
|
13 | |
|
|
14 | This module provides transparent support for AnyEvent. You don't have to |
|
|
15 | do anything to make Glib work with AnyEvent except by loading Glib before |
|
|
16 | creating the first AnyEvent watcher. |
|
|
17 | |
|
|
18 | Glib is probably the most inefficient event loop that has ever seen the |
|
|
19 | light of the world: Glib not only scans all its watchers (really, ALL |
|
|
20 | of them, whether I/O-related, timer-related or not) during each loop |
|
|
21 | iteration, it also does so multiple times and rebuilds the poll list for |
|
|
22 | the kernel each time again, dynamically even. |
|
|
23 | |
|
|
24 | If you create many watchers (as in: more than two), you might consider one |
|
|
25 | of the L<Glib::EV>, L<EV::Glib> or L<Glib::Event> modules that map Glib to |
|
|
26 | other, more efficient, event loops. |
|
|
27 | |
|
|
28 | This module uses the default Glib main context for all it's watchers. |
|
|
29 | |
|
|
30 | =cut |
|
|
31 | |
1 | package AnyEvent::Impl::Glib; |
32 | package AnyEvent::Impl::Glib; |
2 | |
33 | |
3 | no warnings; |
34 | no warnings; |
4 | use strict; |
35 | use strict; |
5 | |
36 | |
6 | use Glib (); |
37 | use Glib (); |
7 | |
38 | |
8 | my $maincontext = Glib::MainContext->default; |
39 | our $maincontext = Glib::MainContext->default; |
9 | |
40 | |
10 | sub io { |
41 | sub io { |
11 | my ($class, %arg) = @_; |
42 | my ($class, %arg) = @_; |
12 | |
43 | |
13 | my $self = bless \%arg, $class; |
44 | my $self = bless \%arg, $class; |
… | |
… | |
51 | |
82 | |
52 | sub one_event { |
83 | sub one_event { |
53 | $maincontext->iteration (1); |
84 | $maincontext->iteration (1); |
54 | } |
85 | } |
55 | |
86 | |
56 | 1 |
87 | 1; |
57 | |
88 | |
|
|
89 | =head1 SEE ALSO |
|
|
90 | |
|
|
91 | L<AnyEvent>, L<Glib>. |
|
|
92 | |
|
|
93 | =head1 AUTHOR |
|
|
94 | |
|
|
95 | Marc Lehmann <schmorp@schmorp.de> |
|
|
96 | http://home.schmorp.de/ |
|
|
97 | |
|
|
98 | =cut |
|
|
99 | |