ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/cfperl.xs
(Generate patch)

Comparing deliantra/server/server/cfperl.xs (file contents):
Revision 1.264 by root, Thu Nov 8 19:43:27 2007 UTC vs.
Revision 1.265 by root, Wed Nov 14 08:09:46 2007 UTC

614 PL_exit_flags |= PERL_EXIT_DESTRUCT_END; 614 PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
615 615
616 const char *argv[] = { 616 const char *argv[] = {
617 settings.argv [0], 617 settings.argv [0],
618 "-e" 618 "-e"
619 "use Event; use Coro;" // required for bootstrap 619 "use EV; use Coro;" // required for bootstrap
620 "cf->bootstrap;" // required for datadir :*> 620 "cf->bootstrap;" // required for datadir :*>
621 "unshift @INC, cf::datadir ();" 621 "unshift @INC, cf::datadir ();"
622 "require cf;" 622 "require cf;"
623 }; 623 };
624 624
625 if (perl_parse (perl, xs_init, 2, (char **)argv, (char **)NULL) 625 if (perl_parse (perl, xs_init, 2, (char **)argv, (char **)NULL)
1099#endif 1099#endif
1100} 1100}
1101 1101
1102///////////////////////////////////////////////////////////////////////////// 1102/////////////////////////////////////////////////////////////////////////////
1103 1103
1104struct EventAPI *watcher_base::GEventAPI; 1104struct EVAPI *evapi::GEVAPI;
1105struct CoroAPI *coroapi::GCoroAPI; 1105struct CoroAPI *coroapi::GCoroAPI;
1106 1106
1107int coroapi::cede_counter; 1107int coroapi::cede_counter;
1108tstamp coroapi::next_cede; 1108tstamp coroapi::next_cede;
1109 1109
1110void coroapi::do_cede_to_tick () 1110void coroapi::do_cede_to_tick ()
1147 CALL_BEGIN (0); 1147 CALL_BEGIN (0);
1148 CALL_CALL ("cf::wait_for_tick_begin", G_DISCARD); 1148 CALL_CALL ("cf::wait_for_tick_begin", G_DISCARD);
1149 CALL_END; 1149 CALL_END;
1150} 1150}
1151 1151
1152static void
1153iw_dispatch (pe_event *ev)
1154{
1155 iw *w = (iw *)ev->ext_data;
1156 w->call (*w);
1157}
1158
1159void
1160iw::alloc ()
1161{
1162 pe = GEventAPI->new_idle (0, 0);
1163
1164 WaREENTRANT_off (pe);
1165 pe->base.callback = (void *)iw_dispatch;
1166 pe->base.ext_data = (void *)this;
1167}
1168
1169static void iow_dispatch (pe_event *ev)
1170{
1171 iow *w = (iow *)ev->ext_data;
1172 w->call (*w, ((pe_ioevent *)ev)->got);
1173}
1174
1175void
1176iow::alloc ()
1177{
1178 pe = GEventAPI->new_io (0, 0);
1179
1180 WaREENTRANT_off (pe);
1181 pe->base.callback = (void *)iow_dispatch;
1182 pe->base.ext_data = (void *)this;
1183
1184 pe->fd = -1;
1185 pe->poll = 0;
1186}
1187
1188void
1189iow::fd (int fd)
1190{
1191 pe->fd = fd;
1192}
1193
1194int
1195iow::poll ()
1196{
1197 return pe->poll;
1198}
1199
1200void 1152void
1201iow::poll (int events) 1153iow::poll (int events)
1202{ 1154{
1203 if (pe->poll != events) 1155 if (events != this->events)
1204 { 1156 {
1157 int active = ev_is_active ((ev_io *)this);
1205 if (pe->poll) stop (); 1158 if (active) stop ();
1206 pe->poll = events; 1159 ev_io_set ((ev_io *)this, fd, events);
1207 if (pe->poll) start (); 1160 if (active) start ();
1208 } 1161 }
1209} 1162}
1210 1163
1211void 1164void
1212_connect_to_perl () 1165_connect_to_perl ()
1237 1190
1238MODULE = cf PACKAGE = cf PREFIX = cf_ 1191MODULE = cf PACKAGE = cf PREFIX = cf_
1239 1192
1240BOOT: 1193BOOT:
1241{ 1194{
1242 I_EVENT_API (PACKAGE); watcher_base::GEventAPI = GEventAPI; 1195 I_EV_API (PACKAGE); evapi::GEVAPI = GEVAPI;
1243 I_CORO_API (PACKAGE); coroapi::GCoroAPI = GCoroAPI; 1196 I_CORO_API (PACKAGE); coroapi::GCoroAPI = GCoroAPI;
1244 1197
1245 _connect_to_perl (); 1198 _connect_to_perl ();
1246 1199
1247 newCONSTSUB (stash_cf, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1)); 1200 newCONSTSUB (stash_cf, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1));
1248 1201
1712 1665
1713void emergency_save () 1666void emergency_save ()
1714 1667
1715void _exit (int status = EXIT_SUCCESS) 1668void _exit (int status = EXIT_SUCCESS)
1716 1669
1717UV sv_2watcher (SV *w)
1718 CODE:
1719 RETVAL = (UV)GEventAPI->sv_2watcher (w);
1720 OUTPUT:
1721 RETVAL
1722
1723#if _POSIX_MEMLOCK 1670#if _POSIX_MEMLOCK
1724 1671
1725int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) 1672int mlockall (int flags = MCL_CURRENT | MCL_FUTURE)
1726 1673
1727int munlockall () 1674int munlockall ()

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines