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

Comparing deliantra/server/include/cfperl.h (file contents):
Revision 1.35 by root, Thu Dec 14 05:09:32 2006 UTC vs.
Revision 1.36 by root, Thu Dec 14 20:39:54 2006 UTC

9using namespace std; 9using namespace std;
10 10
11#include <EXTERN.h> 11#include <EXTERN.h>
12#include <perl.h> 12#include <perl.h>
13#include <XSUB.h> 13#include <XSUB.h>
14
15#include <EventAPI.h>
16
17#include "callback.h"
14 18
15// optimisations/workaround for functions requiring my_perl in scope (anti-bloat) 19// optimisations/workaround for functions requiring my_perl in scope (anti-bloat)
16#undef localtime 20#undef localtime
17#undef srand48 21#undef srand48
18#undef drand48 22#undef drand48
324 void get (sint64 &i) { i = get_sint64 (); } 328 void get (sint64 &i) { i = get_sint64 (); }
325}; 329};
326 330
327char *fgets (char *s, int n, object_thawer &thawer); 331char *fgets (char *s, int n, object_thawer &thawer);
328 332
333struct watcher_base
334{
335 static struct EventAPI *GEventAPI;
336};
337
338template<class base>
339struct watcher : watcher_base
340{
341 base *pe;
342
343 void start (bool repeat = false) { GEventAPI->start ((pe_watcher *)pe, repeat); }
344 void stop (bool cancel_events = false) { GEventAPI->stop ((pe_watcher *)pe, cancel_events); }
345 void now () { GEventAPI->now ((pe_watcher *)pe); }
346 void suspend () { GEventAPI->suspend ((pe_watcher *)pe); }
347 void resume () { GEventAPI->resume ((pe_watcher *)pe); }
348
349 void prio (int new_prio) { ((pe_watcher *)pe)->prio = new_prio; }
350
351 ~watcher ()
352 {
353 cancel ();
354 }
355
356private:
357 void cancel () { GEventAPI->cancel ((pe_watcher *)pe); } // private
358};
359
360struct iow : watcher<pe_io>, callback<void (iow &, int)>
361{
362 template<class O, class M>
363 iow (O object, M method)
364 : callback<void (iow &, int)> (object, method)
365 {
366 alloc ();
367 }
368
369 iow &fd (int fd);
370 int poll ();
371 iow &poll (int events);
372
373private:
374 void alloc ();
375};
376
329#endif 377#endif
330 378

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines