… | |
… | |
966 | You should check C<$AnyEvent::MODEL> before adding to this array, though: |
966 | You should check C<$AnyEvent::MODEL> before adding to this array, though: |
967 | if it is defined then the event loop has already been detected, and the |
967 | if it is defined then the event loop has already been detected, and the |
968 | array will be ignored. |
968 | array will be ignored. |
969 | |
969 | |
970 | Best use C<AnyEvent::post_detect { BLOCK }> when your application allows |
970 | Best use C<AnyEvent::post_detect { BLOCK }> when your application allows |
971 | it,as it takes care of these details. |
971 | it, as it takes care of these details. |
972 | |
972 | |
973 | This variable is mainly useful for modules that can do something useful |
973 | This variable is mainly useful for modules that can do something useful |
974 | when AnyEvent is used and thus want to know when it is initialised, but do |
974 | when AnyEvent is used and thus want to know when it is initialised, but do |
975 | not need to even load it by default. This array provides the means to hook |
975 | not need to even load it by default. This array provides the means to hook |
976 | into AnyEvent passively, without loading it. |
976 | into AnyEvent passively, without loading it. |
|
|
977 | |
|
|
978 | Example: To load Coro::AnyEvent whenever Coro and AnyEvent are used |
|
|
979 | together, you could put this into Coro (this is the actual code used by |
|
|
980 | Coro to accomplish this): |
|
|
981 | |
|
|
982 | if (defined $AnyEvent::MODEL) { |
|
|
983 | # AnyEvent already initialised, so load Coro::AnyEvent |
|
|
984 | require Coro::AnyEvent; |
|
|
985 | } else { |
|
|
986 | # AnyEvent not yet initialised, so make sure to load Coro::AnyEvent |
|
|
987 | # as soon as it is |
|
|
988 | push @AnyEvent::post_detect, sub { require Coro::AnyEvent }; |
|
|
989 | } |
977 | |
990 | |
978 | =back |
991 | =back |
979 | |
992 | |
980 | =head1 WHAT TO DO IN A MODULE |
993 | =head1 WHAT TO DO IN A MODULE |
981 | |
994 | |
… | |
… | |
1131 | package AnyEvent; |
1144 | package AnyEvent; |
1132 | |
1145 | |
1133 | # basically a tuned-down version of common::sense |
1146 | # basically a tuned-down version of common::sense |
1134 | sub common_sense { |
1147 | sub common_sense { |
1135 | # from common:.sense 1.0 |
1148 | # from common:.sense 1.0 |
1136 | ${^WARNING_BITS} = "\xfc\x3f\x33\x00\x0f\xf3\xcf\xc0\xf3\xfc\x33\x03"; |
1149 | ${^WARNING_BITS} = "\xfc\x3f\x33\x00\x0f\xf3\xcf\xc0\xf3\xfc\x33\x00"; |
1137 | # use strict vars subs |
1150 | # use strict vars subs |
1138 | $^H |= 0x00000600; |
1151 | $^H |= 0x00000600; |
1139 | } |
1152 | } |
1140 | |
1153 | |
1141 | BEGIN { AnyEvent::common_sense } |
1154 | BEGIN { AnyEvent::common_sense } |