… | |
… | |
687 | |
687 | |
688 | while ($busy) { |
688 | while ($busy) { |
689 | if (Coro::nready) { |
689 | if (Coro::nready) { |
690 | Coro::cede_notself; |
690 | Coro::cede_notself; |
691 | } else { |
691 | } else { |
692 | EV::loop EV::LOOP_ONESHOT; |
692 | EV::run EV::RUN_ONESHOT; |
693 | } |
693 | } |
694 | } |
694 | } |
695 | |
695 | |
696 | my $time = AE::time - $time; |
696 | my $time = AE::time - $time; |
697 | |
697 | |
… | |
… | |
2787 | The player should be reasonably safe there for short amounts of time (e.g. |
2787 | The player should be reasonably safe there for short amounts of time (e.g. |
2788 | for loading a map). You I<MUST> call C<leave_link> as soon as possible, |
2788 | for loading a map). You I<MUST> call C<leave_link> as soon as possible, |
2789 | though, as the player cannot control the character while it is on the link |
2789 | though, as the player cannot control the character while it is on the link |
2790 | map. |
2790 | map. |
2791 | |
2791 | |
2792 | Will never block. |
2792 | This method will never block, which is the whole reaosn for it's |
|
|
2793 | existance: you can I<always> put a player onto the link map, which is the |
|
|
2794 | only place to put objects that is guaranteed to exist. |
|
|
2795 | |
|
|
2796 | A typical usage pattern is to call C<enter_link> synchronously from the |
|
|
2797 | server, then start a new thread, do your blocking stuff there and then |
|
|
2798 | call C<leave_link> from that thread. |
2793 | |
2799 | |
2794 | =item $player_object->leave_link ($map, $x, $y) |
2800 | =item $player_object->leave_link ($map, $x, $y) |
2795 | |
2801 | |
2796 | Moves the player out of the special C<{link}> map onto the specified |
2802 | Moves the player out of the special C<{link}> map onto the specified |
2797 | map. If the map is not valid (or omitted), the player will be moved back |
2803 | map. If the map is not valid (or omitted), the player will be moved back |
… | |
… | |
3909 | seek $fh, 0, 0; |
3915 | seek $fh, 0, 0; |
3910 | print $fh $$; |
3916 | print $fh $$; |
3911 | } |
3917 | } |
3912 | |
3918 | |
3913 | sub main_loop { |
3919 | sub main_loop { |
3914 | trace "EV::loop starting\n"; |
3920 | trace "EV::run starting\n"; |
3915 | if (1) { |
3921 | if (1) { |
3916 | EV::loop; |
3922 | EV::run; |
3917 | } |
3923 | } |
3918 | trace "EV::loop returned\n"; |
3924 | trace "EV::run returned\n"; |
3919 | goto &main_loop unless $REALLY_UNLOOP; |
3925 | goto &main_loop unless $REALLY_UNLOOP; |
3920 | } |
3926 | } |
3921 | |
3927 | |
3922 | sub main { |
3928 | sub main { |
3923 | cf::init_globals; # initialise logging |
3929 | cf::init_globals; # initialise logging |
… | |
… | |
3932 | # we must not ever block the main coroutine |
3938 | # we must not ever block the main coroutine |
3933 | $Coro::idle = sub { |
3939 | $Coro::idle = sub { |
3934 | Carp::cluck "FATAL: Coro::idle was called, major BUG, use cf::sync_job!\n";#d# |
3940 | Carp::cluck "FATAL: Coro::idle was called, major BUG, use cf::sync_job!\n";#d# |
3935 | (async { |
3941 | (async { |
3936 | $Coro::current->{desc} = "IDLE BUG HANDLER"; |
3942 | $Coro::current->{desc} = "IDLE BUG HANDLER"; |
3937 | EV::loop EV::LOOP_ONESHOT; |
3943 | EV::run EV::RUN_ONESHOT; |
3938 | })->prio (Coro::PRIO_MAX); |
3944 | })->prio (Coro::PRIO_MAX); |
3939 | }; |
3945 | }; |
3940 | |
3946 | |
3941 | evthread_start IO::AIO::poll_fileno; |
3947 | evthread_start IO::AIO::poll_fileno; |
3942 | |
3948 | |