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.86 by root, Thu Dec 14 05:09:32 2006 UTC vs.
Revision 1.87 by root, Thu Dec 14 22:45:40 2006 UTC

15 15
16# work around bug in YAML::Syck - bad news for perl6, will it be as broken wrt. unicode? 16# work around bug in YAML::Syck - bad news for perl6, will it be as broken wrt. unicode?
17$YAML::Syck::ImplicitUnicode = 1; 17$YAML::Syck::ImplicitUnicode = 1;
18 18
19use strict; 19use strict;
20
21sub WF_AUTOCANCEL () { 1 } # automatically cancel this watcher on reload
20 22
21our %COMMAND = (); 23our %COMMAND = ();
22our %COMMAND_TIME = (); 24our %COMMAND_TIME = ();
23our %EXTCMD = (); 25our %EXTCMD = ();
24 26
1023 sub db_sync() { 1025 sub db_sync() {
1024 db_save if $dirty; 1026 db_save if $dirty;
1025 undef $dirty; 1027 undef $dirty;
1026 } 1028 }
1027 1029
1028 my $idle = Event->idle (min => $TICK * 2.8, max => 10, repeat => 0, cb => sub { 1030 my $idle = Event->idle (min => $TICK * 2.8, max => 10, repeat => 0, data => WF_AUTOCANCEL, cb => sub {
1029 db_sync; 1031 db_sync;
1030 }); 1032 });
1031 1033
1032 sub db_dirty() { 1034 sub db_dirty() {
1033 $dirty = 1; 1035 $dirty = 1;
1083 1085
1084 $msg->("reloading..."); 1086 $msg->("reloading...");
1085 1087
1086 eval { 1088 eval {
1087 # cancel all watchers 1089 # cancel all watchers
1088 $_->cancel for Event::all_watchers; 1090 for (Event::all_watchers) {
1091 $_->cancel if $_->data & WF_AUTOCANCEL;
1092 }
1089 1093
1090 # unload all extensions 1094 # unload all extensions
1091 for (@exts) { 1095 for (@exts) {
1092 $msg->("unloading <$_>"); 1096 $msg->("unloading <$_>");
1093 unload_extension $_; 1097 unload_extension $_;
1172 1176
1173$TICK_WATCHER = Event->timer ( 1177$TICK_WATCHER = Event->timer (
1174 prio => 1, 1178 prio => 1,
1175 async => 1, 1179 async => 1,
1176 at => $NEXT_TICK || 1, 1180 at => $NEXT_TICK || 1,
1181 data => WF_AUTOCANCEL,
1177 cb => sub { 1182 cb => sub {
1178 cf::server_tick; # one server iteration 1183 cf::server_tick; # one server iteration
1179 1184
1180 my $NOW = Event::time; 1185 my $NOW = Event::time;
1181 $NEXT_TICK += $TICK; 1186 $NEXT_TICK += $TICK;
1191IO::AIO::max_poll_time $TICK * 0.2; 1196IO::AIO::max_poll_time $TICK * 0.2;
1192 1197
1193Event->io (fd => IO::AIO::poll_fileno, 1198Event->io (fd => IO::AIO::poll_fileno,
1194 poll => 'r', 1199 poll => 'r',
1195 prio => 5, 1200 prio => 5,
1201 data => WF_AUTOCANCEL,
1196 cb => \&IO::AIO::poll_cb); 1202 cb => \&IO::AIO::poll_cb);
1197 1203
11981 12041
1199 1205

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines