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.43 by root, Sat Dec 30 15:07:59 2006 UTC vs.
Revision 1.47 by root, Sun Jan 7 02:39:14 2007 UTC

35 35
36// same here, massive symbol spamming 36// same here, massive symbol spamming
37#undef do_open 37#undef do_open
38#undef do_close 38#undef do_close
39#undef ref 39#undef ref
40#undef seed
40 41
41// perl bug #40256: perl does overwrite those with reentrant versions 42// perl bug #40256: perl does overwrite those with reentrant versions
42// but does not initialise their state structures. 43// but does not initialise their state structures.
43#undef random 44#undef random
44#undef crypt 45#undef crypt
119double cfperl_result_DOUBLE (int idx); 120double cfperl_result_DOUBLE (int idx);
120int cfperl_result_INT (int idx); 121int cfperl_result_INT (int idx);
121 122
122////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 123//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
123 124
125INTERFACE_CLASS (attachable)
124struct attachable 126struct attachable
125{ 127{
126 static MGVTBL vtbl; 128 static MGVTBL vtbl;
127 129
128 static unordered_vector<attachable *> mortals; 130 static unordered_vector<attachable *> mortals;
129 static void check_mortals (); 131 MTH static void check_mortals ();
130 132
131 enum { 133 enum {
132 F_DESTROYED = 0x01, 134 F_DESTROYED = 0x01,
133 F_BORROWED = 0x02, 135 F_BORROWED = 0x02,
134 }; 136 };
135 137
136 // object is delete'd after the refcount reaches 0 138 // object is delete'd after the refcount reaches 0
137 mutable int refcnt; 139 mutable int ACC (RW, refcnt);
138 int flags; 140 int ACC (RW, flags);
139 141
140 void refcnt_inc () const { ++refcnt; } 142 MTH void refcnt_inc () const { ++refcnt; }
141 void refcnt_dec () const { --refcnt; } 143 MTH void refcnt_dec () const { --refcnt; }
142 144
143 // check wether the object has died and destroy 145 // check wether the object has died and destroy
144 void refcnt_chk () { if (refcnt <= 0) do_check (); } 146 MTH void refcnt_chk () { if (refcnt <= 0) do_check (); }
145 147
146 // destroy the object unless it was already destroyed 148 // destroy the object unless it was already destroyed
147 // this politely asks everybody interested the reduce 149 // this politely asks everybody interested the reduce
148 // the refcount to 0 as soon as possible. 150 // the refcount to 0 as soon as possible.
149 void destroy (); 151 MTH void destroy ();
150 152
151 // return wether an object was destroyed already 153 // return wether an object was destroyed already
152 bool destroyed () const { return flags & F_DESTROYED; } 154 MTH bool destroyed () const { return flags & F_DESTROYED; }
153 155
154 virtual void gather_callbacks (AV *&callbacks, event_type event) const; 156 virtual void gather_callbacks (AV *&callbacks, event_type event) const;
155 157
156#if 0 158#if 0
157private: 159private:
247 } 249 }
248 250
249 *p = '\n'; 251 *p = '\n';
250 } 252 }
251 253
252 void put (keyword k, const char *v) 254 void put (keyword k, const char *v = 0)
253 { 255 {
254 put_string (k, v); 256 put_string (k, v);
255 } 257 }
256 258
257 void put (keyword k, const shstr &v) 259 void put (keyword k, const shstr &v)
322 void put (keyword k, const refptr<T> &v) 324 void put (keyword k, const refptr<T> &v)
323 { 325 {
324 put (k, (T *)v); 326 put (k, (T *)v);
325 } 327 }
326 328
327 bool save (const char *filename); 329 bool save (const char *path);
328 char *as_string (); // like strdup 330 char *as_string (); // like strdup
329 331
330 operator bool () { return !!av; } 332 operator bool () { return !!av; }
331}; 333};
332 334
338{ 340{
339 SV *text; // text part 341 SV *text; // text part
340 AV *av; // perl part 342 AV *av; // perl part
341 char *line; // current beginning of line 343 char *line; // current beginning of line
342 char *last_keyword, *last_value; 344 char *last_keyword, *last_value;
345 const char *name;
343 346
344 operator bool () { return !!text; } 347 operator bool () { return !!text; }
345 348
346 object_thawer (const char *filename = 0); 349 object_thawer (const char *path = 0);
347 object_thawer (const char *data, AV *perlav); 350 object_thawer (const char *data, AV *perlav);
348 ~object_thawer (); 351 ~object_thawer ();
349 352
350 void get (attachable *obj, int oid); 353 void get (attachable *obj, int oid);
351 354
383struct coroapi { 386struct coroapi {
384 static struct CoroAPI *GCoroAPI; 387 static struct CoroAPI *GCoroAPI;
385 388
386 static int nready () { return CORO_NREADY; } 389 static int nready () { return CORO_NREADY; }
387 static int cede () { return CORO_CEDE ; } 390 static int cede () { return CORO_CEDE ; }
391
392 static int cede_counter;
393
394 static void cede_every (int count)
395 {
396 if (++cede_counter >= count)
397 {
398 cede_counter = 0;
399
400 if (coroapi::nready ())
401 coroapi::cede ();
402 }
403 }
388}; 404};
389 405
390struct watcher_base 406struct watcher_base
391{ 407{
392 static struct EventAPI *GEventAPI; 408 static struct EventAPI *GEventAPI;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines