ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/lib/cf.pm
(Generate patch)

Comparing deliantra/server/lib/cf.pm (file contents):
Revision 1.545 by root, Thu May 6 22:35:41 2010 UTC vs.
Revision 1.546 by root, Thu May 6 22:57:49 2010 UTC

233from wherever your confdir points to. 233from wherever your confdir points to.
234 234
235=item cf::wait_for_tick, cf::wait_for_tick_begin 235=item cf::wait_for_tick, cf::wait_for_tick_begin
236 236
237These are functions that inhibit the current coroutine one tick. cf::wait_for_tick_begin only 237These are functions that inhibit the current coroutine one tick. cf::wait_for_tick_begin only
238returns directly I<after> the tick processing (and consequently, can only wake one process 238returns directly I<after> the tick processing (and consequently, can only wake one thread
239per tick), while cf::wait_for_tick wakes up all waiters after tick processing. 239per tick), while cf::wait_for_tick wakes up all waiters after tick processing.
240
241=cut
242
243sub wait_for_tick();
244sub wait_for_tick_begin();
240 245
241=item @cf::INVOKE_RESULTS 246=item @cf::INVOKE_RESULTS
242 247
243This array contains the results of the last C<invoke ()> call. When 248This array contains the results of the last C<invoke ()> call. When
244C<cf::override> is called C<@cf::INVOKE_RESULTS> is set to the parameters of 249C<cf::override> is called C<@cf::INVOKE_RESULTS> is set to the parameters of
3370 3375
3371 my $enc = JSON::XS->new->utf8->canonical->relaxed; 3376 my $enc = JSON::XS->new->utf8->canonical->relaxed;
3372 3377
3373 trace "loading facedata from $path\n"; 3378 trace "loading facedata from $path\n";
3374 3379
3375 my $facedata;
3376 0 < aio_load $path, $facedata 3380 0 < aio_load $path, my $facedata
3377 or die "$path: $!"; 3381 or die "$path: $!";
3378 3382
3379 $facedata = Coro::Storable::thaw $facedata; 3383 $facedata = Coro::Storable::thaw $facedata;
3380 3384
3381 $facedata->{version} == 2 3385 $facedata->{version} == 2
3539} 3543}
3540 3544
3541sub reload_config { 3545sub reload_config {
3542 trace "reloading config file...\n"; 3546 trace "reloading config file...\n";
3543 3547
3544 open my $fh, "<:utf8", "$CONFDIR/config" 3548 0 < aio_load "$CONFDIR/config", my $config
3545 or return; 3549 or die "$CONFDIR/config: $!";
3546 3550
3547 local $/; 3551 utf8::decode $config;
3552
3553 cf::get_slot 0.1, 10, "reload_config"; # yaml might be slow...
3548 *CFG = YAML::XS::Load scalar <$fh>; 3554 *CFG = YAML::XS::Load $config;
3549 3555
3550 $EMERGENCY_POSITION = $CFG{emergency_position} || ["/world/world_104_115", 49, 38]; 3556 $EMERGENCY_POSITION = $CFG{emergency_position} || ["/world/world_104_115", 49, 38];
3551 3557
3552 $cf::map::MAX_RESET = $CFG{map_max_reset} if exists $CFG{map_max_reset}; 3558 $cf::map::MAX_RESET = $CFG{map_max_reset} if exists $CFG{map_max_reset};
3553 $cf::map::DEFAULT_RESET = $CFG{map_default_reset} if exists $CFG{map_default_reset}; 3559 $cf::map::DEFAULT_RESET = $CFG{map_default_reset} if exists $CFG{map_default_reset};
3557 $CFG{mlockall} ? eval "mlockall()" : eval "munlockall()" 3563 $CFG{mlockall} ? eval "mlockall()" : eval "munlockall()"
3558 and die "WARNING: m(un)lockall failed: $!\n"; 3564 and die "WARNING: m(un)lockall failed: $!\n";
3559 }; 3565 };
3560 warn $@ if $@; 3566 warn $@ if $@;
3561 } 3567 }
3562
3563 trace "finished reloading resource files\n";
3564} 3568}
3565 3569
3566sub pidfile() { 3570sub pidfile() {
3567 sysopen my $fh, $PIDFILE, O_RDWR | O_CREAT 3571 sysopen my $fh, $PIDFILE, O_RDWR | O_CREAT
3568 or die "$PIDFILE: $!"; 3572 or die "$PIDFILE: $!";
4009my $bug_warning = 0; 4013my $bug_warning = 0;
4010 4014
4011our @WAIT_FOR_TICK; 4015our @WAIT_FOR_TICK;
4012our @WAIT_FOR_TICK_BEGIN; 4016our @WAIT_FOR_TICK_BEGIN;
4013 4017
4014sub wait_for_tick { 4018sub wait_for_tick() {
4015 return Coro::cede if tick_inhibit || $Coro::current == $Coro::main; 4019 return Coro::cede if tick_inhibit || $Coro::current == $Coro::main;
4016 4020
4017 my $signal = new Coro::Signal; 4021 my $signal = new Coro::Signal;
4018 push @WAIT_FOR_TICK, $signal; 4022 push @WAIT_FOR_TICK, $signal;
4019 $signal->wait; 4023 $signal->wait;
4020} 4024}
4021 4025
4022sub wait_for_tick_begin { 4026sub wait_for_tick_begin() {
4023 return Coro::cede if tick_inhibit || $Coro::current == $Coro::main; 4027 return Coro::cede if tick_inhibit || $Coro::current == $Coro::main;
4024 4028
4025 my $signal = new Coro::Signal; 4029 my $signal = new Coro::Signal;
4026 push @WAIT_FOR_TICK_BEGIN, $signal; 4030 push @WAIT_FOR_TICK_BEGIN, $signal;
4027 $signal->wait; 4031 $signal->wait;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines