1 |
root |
1.1 |
=head1 NAME |
2 |
|
|
|
3 |
|
|
Glib::EV - Coerce Glib into using the EV module as event loop. |
4 |
|
|
|
5 |
|
|
=head1 SYNOPSIS |
6 |
|
|
|
7 |
|
|
use Glib::EV; |
8 |
|
|
|
9 |
|
|
# example with Gtk2: |
10 |
|
|
use Gtk2 -init; |
11 |
|
|
use Glib::EV; |
12 |
|
|
use EV; # any order |
13 |
|
|
my $timer = EV::timer 1, 1, sub { print "I am here!\n" }; |
14 |
|
|
main Gtk2; |
15 |
|
|
# etc., it just works |
16 |
|
|
|
17 |
|
|
# You can even move the glib mainloop into a coroutine: |
18 |
|
|
use Gtk2 -init; |
19 |
|
|
use Coro; |
20 |
|
|
use Coro::EV; |
21 |
|
|
use Glib::EV; |
22 |
|
|
async { main Gtk2 }; |
23 |
|
|
# ... do other things |
24 |
|
|
|
25 |
|
|
=head1 DESCRIPTION |
26 |
|
|
|
27 |
root |
1.3 |
If you want to use glib/gtk+ in an EV program, then you need to look at |
28 |
|
|
the EV::Glib module, not this one, as this module requires you to run a |
29 |
|
|
Glib or Gtk+ main loop in your program. |
30 |
|
|
|
31 |
|
|
If you want to use EV in an Glib/Gtk+ program, you are at the right place |
32 |
|
|
here. |
33 |
|
|
|
34 |
root |
1.1 |
This module coerces the Glib event loop to use the EV high performance |
35 |
|
|
event loop as underlying event loop, i.e. EV will be used by Glib for all |
36 |
|
|
events. |
37 |
|
|
|
38 |
|
|
This makes Glib compatible to EV. Calls into the Glib main loop are more |
39 |
|
|
or less equivalent to calls to C<EV::loop> (but not vice versa, you |
40 |
|
|
I<have> to use the Glib mainloop functions). |
41 |
|
|
|
42 |
|
|
=over 4 |
43 |
|
|
|
44 |
|
|
=item * The Glib perl module is not used. |
45 |
|
|
|
46 |
|
|
This module has no dependency on the existing Glib perl interface, as it |
47 |
|
|
uses glib directly. The Glib module can, however, be used without any |
48 |
root |
1.4 |
problems (as long as everybody uses shared libraries to keep everybody |
49 |
root |
1.1 |
else happy). |
50 |
|
|
|
51 |
|
|
=item * The default context will be changed when the module is loaded. |
52 |
|
|
|
53 |
|
|
Loading this module will automatically "patch" the default context of |
54 |
|
|
libglib, so normally nothing more is required. |
55 |
|
|
|
56 |
|
|
=item * Glib does not allow recursive invocations. |
57 |
|
|
|
58 |
|
|
This means that none of your event watchers might call into Glib |
59 |
|
|
functions or functions that might call glib functions (basically all Gtk2 |
60 |
|
|
functions). It might work, but that's your problem.... |
61 |
|
|
|
62 |
|
|
=cut |
63 |
|
|
|
64 |
|
|
package Glib::EV; |
65 |
|
|
|
66 |
|
|
use Carp (); |
67 |
|
|
use EV (); |
68 |
|
|
|
69 |
|
|
our $default_poll_func; |
70 |
|
|
|
71 |
|
|
BEGIN { |
72 |
root |
1.5 |
$VERSION = '2.02'; |
73 |
root |
1.1 |
|
74 |
|
|
require XSLoader; |
75 |
|
|
XSLoader::load (Glib::EV, $VERSION); |
76 |
|
|
|
77 |
|
|
$default_poll_func = install (undef); |
78 |
|
|
} |
79 |
|
|
|
80 |
|
|
=back |
81 |
|
|
|
82 |
|
|
=cut |
83 |
|
|
|
84 |
|
|
=head1 BUGS |
85 |
|
|
|
86 |
|
|
* No documented API to patch other main contexts. |
87 |
|
|
|
88 |
|
|
=head1 SEE ALSO |
89 |
|
|
|
90 |
|
|
L<EV>, L<Glib>, L<Glib::MainLoop>. |
91 |
|
|
|
92 |
|
|
=head1 AUTHOR |
93 |
|
|
|
94 |
|
|
Marc Lehmann <schmorp@schmorp.de> |
95 |
|
|
http://home.schmorp.de/ |
96 |
|
|
|
97 |
|
|
=cut |
98 |
|
|
|
99 |
|
|
1 |
100 |
|
|
|