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.59 by root, Thu Mar 1 19:32:58 2007 UTC vs.
Revision 1.64 by root, Sat May 19 00:08:11 2007 UTC

2// cfperl.h perl interface 2// cfperl.h perl interface
3// 3//
4#ifndef CFPERL_H__ 4#ifndef CFPERL_H__
5#define CFPERL_H__ 5#define CFPERL_H__
6 6
7#include <cstdarg>
7#include <cstdio> 8#include <cstdio>
9#include <bitset>
8 10
9using namespace std; 11using namespace std;
10 12
11#include <EXTERN.h> 13#include <EXTERN.h>
12#include <perl.h> 14#include <perl.h>
87# define def(klass,name) EVENT_ ## klass ## _ ## name, 89# define def(klass,name) EVENT_ ## klass ## _ ## name,
88# include "eventinc.h" 90# include "eventinc.h"
89# undef def 91# undef def
90 NUM_EVENT_TYPES 92 NUM_EVENT_TYPES
91}; 93};
94
95// in which global events or per-type events are we interested
96extern bitset<NUM_EVENT_TYPES> ev_want_event;
97extern bitset<NUM_TYPES> ev_want_type;
92 98
93#define ARG_AV(o) DT_AV , static_cast<AV *> (o) 99#define ARG_AV(o) DT_AV , static_cast<AV *> (o)
94#define ARG_INT(v) DT_INT , static_cast<int> (v) 100#define ARG_INT(v) DT_INT , static_cast<int> (v)
95#define ARG_INT64(v) DT_INT64 , static_cast<sint64> (v) 101#define ARG_INT64(v) DT_INT64 , static_cast<sint64> (v)
96#define ARG_DOUBLE(v) DT_DOUBLE, static_cast<double> (v) 102#define ARG_DOUBLE(v) DT_DOUBLE, static_cast<double> (v)
183 189
184 virtual ~attachable (); 190 virtual ~attachable ();
185 191
186 attachable &operator =(const attachable &src); 192 attachable &operator =(const attachable &src);
187 193
194 bool vinvoke (event_type event, va_list &ap);
188 bool invoke (event_type event, ...); 195 bool invoke (event_type event, ...)
196 {
197 if (ev_want_event [event] || cb)
198 {
199 va_list ap;
200 va_start (ap, event);
201 vinvoke (event, ap);
202 va_end (ap);
203 }
204 }
205
189 MTH void instantiate (); 206 MTH void instantiate ();
190 void reattach (); 207 void reattach ();
191 208
192protected: 209protected:
193 // do the real refcount checking work 210 // do the real refcount checking work
205 222
206extern struct global gbl_ev; 223extern struct global gbl_ev;
207 224
208////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 225//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
209 226
210struct object_freezer : dynbuf 227struct object_freezer : dynbuf_text
211{ 228{
212 AV *av; 229 AV *av;
213 230
214 object_freezer (); 231 object_freezer ();
215 ~object_freezer (); 232 ~object_freezer ();
369 { 386 {
370 next (); 387 next ();
371 return kw; 388 return kw;
372 } 389 }
373 390
374
375 char *get_str () { return value; } // may be 0 391 char *get_str () { return value; } // may be 0
376 392
377 void get (shstr &sh) const; 393 void get (shstr &sh) const;
378 void get_ornull (shstr &sh) const { sh = value; } 394 void get_ornull (shstr &sh) const { sh = value; }
379 void get_ml (keyword kend, shstr &sh); 395 void get_ml (keyword kend, shstr &sh);
407 static struct CoroAPI *GCoroAPI; 423 static struct CoroAPI *GCoroAPI;
408 424
409 static int nready () { return CORO_NREADY; } 425 static int nready () { return CORO_NREADY; }
410 static int cede () { return CORO_CEDE ; } 426 static int cede () { return CORO_CEDE ; }
411 427
428 static double (*time)();
429 static double next_cede;
412 static int cede_counter; 430 static int cede_counter;
413 431
432 static void do_cede_every ();
433 static void do_cede_to_tick ();
434 static void do_cede_to_tick_every ();
435
414 static void cede_every (int count) 436 static void cede_every (int count)
415 { 437 {
416 if (++cede_counter >= count) 438 if (++cede_counter >= count)
417 { 439 do_cede_every ();
418 cede_counter = 0;
419
420 if (coroapi::nready ())
421 coroapi::cede ();
422 }
423 } 440 }
441
442 static void cede_to_tick ()
443 {
444 if (time () >= next_cede)
445 do_cede_to_tick ();
446 }
447
448 static void cede_to_tick_every (int count)
449 {
450 if (++cede_counter >= count)
451 cede_to_tick ();
452 }
453
454 static void wait_for_tick ();
455 static void wait_for_tick_begin ();
424}; 456};
425 457
426struct watcher_base 458struct watcher_base
427{ 459{
428 static struct EventAPI *GEventAPI; 460 static struct EventAPI *GEventAPI;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines