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.85 by root, Mon Dec 11 22:56:57 2006 UTC vs.
Revision 1.87 by root, Thu Dec 14 22:45:40 2006 UTC

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 20
21sub WF_AUTOCANCEL () { 1 } # automatically cancel this watcher on reload
22
21our %COMMAND = (); 23our %COMMAND = ();
22our %COMMAND_TIME = (); 24our %COMMAND_TIME = ();
23our %EXTCMD = (); 25our %EXTCMD = ();
24 26
25_init_vars; 27_init_vars;
76 78
77@safe::cf::object::player::ISA = @cf::object::player::ISA = 'cf::object'; 79@safe::cf::object::player::ISA = @cf::object::player::ISA = 'cf::object';
78 80
79# we bless all objects into (empty) derived classes to force a method lookup 81# we bless all objects into (empty) derived classes to force a method lookup
80# within the Safe compartment. 82# within the Safe compartment.
81for my $pkg (qw(cf::object cf::object::player cf::player cf::map cf::party cf::region cf::arch cf::living)) { 83for my $pkg (qw(
84 cf::object cf::object::player
85 cf::client_socket cf::player
86 cf::arch cf::living
87 cf::map cf::party cf::region
88)) {
82 no strict 'refs'; 89 no strict 'refs';
83 @{"safe::$pkg\::wrap::ISA"} = @{"$pkg\::wrap::ISA"} = $pkg; 90 @{"safe::$pkg\::wrap::ISA"} = @{"$pkg\::wrap::ISA"} = $pkg;
84} 91}
85 92
86$Event::DIED = sub { 93$Event::DIED = sub {
1018 sub db_sync() { 1025 sub db_sync() {
1019 db_save if $dirty; 1026 db_save if $dirty;
1020 undef $dirty; 1027 undef $dirty;
1021 } 1028 }
1022 1029
1023 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 {
1024 db_sync; 1031 db_sync;
1025 }); 1032 });
1026 1033
1027 sub db_dirty() { 1034 sub db_dirty() {
1028 $dirty = 1; 1035 $dirty = 1;
1078 1085
1079 $msg->("reloading..."); 1086 $msg->("reloading...");
1080 1087
1081 eval { 1088 eval {
1082 # cancel all watchers 1089 # cancel all watchers
1083 $_->cancel for Event::all_watchers; 1090 for (Event::all_watchers) {
1091 $_->cancel if $_->data & WF_AUTOCANCEL;
1092 }
1084 1093
1085 # unload all extensions 1094 # unload all extensions
1086 for (@exts) { 1095 for (@exts) {
1087 $msg->("unloading <$_>"); 1096 $msg->("unloading <$_>");
1088 unload_extension $_; 1097 unload_extension $_;
1167 1176
1168$TICK_WATCHER = Event->timer ( 1177$TICK_WATCHER = Event->timer (
1169 prio => 1, 1178 prio => 1,
1170 async => 1, 1179 async => 1,
1171 at => $NEXT_TICK || 1, 1180 at => $NEXT_TICK || 1,
1181 data => WF_AUTOCANCEL,
1172 cb => sub { 1182 cb => sub {
1173 cf::server_tick; # one server iteration 1183 cf::server_tick; # one server iteration
1174 1184
1175 my $NOW = Event::time; 1185 my $NOW = Event::time;
1176 $NEXT_TICK += $TICK; 1186 $NEXT_TICK += $TICK;
1186IO::AIO::max_poll_time $TICK * 0.2; 1196IO::AIO::max_poll_time $TICK * 0.2;
1187 1197
1188Event->io (fd => IO::AIO::poll_fileno, 1198Event->io (fd => IO::AIO::poll_fileno,
1189 poll => 'r', 1199 poll => 'r',
1190 prio => 5, 1200 prio => 5,
1201 data => WF_AUTOCANCEL,
1191 cb => \&IO::AIO::poll_cb); 1202 cb => \&IO::AIO::poll_cb);
1192 1203
11931 12041
1194 1205

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines