--- deliantra/server/include/cfperl.h 2006/12/30 15:07:59 1.43 +++ deliantra/server/include/cfperl.h 2007/01/07 02:39:14 1.47 @@ -37,6 +37,7 @@ #undef do_open #undef do_close #undef ref +#undef seed // perl bug #40256: perl does overwrite those with reentrant versions // but does not initialise their state structures. @@ -121,12 +122,13 @@ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +INTERFACE_CLASS (attachable) struct attachable { static MGVTBL vtbl; static unordered_vector mortals; - static void check_mortals (); + MTH static void check_mortals (); enum { F_DESTROYED = 0x01, @@ -134,22 +136,22 @@ }; // object is delete'd after the refcount reaches 0 - mutable int refcnt; - int flags; + mutable int ACC (RW, refcnt); + int ACC (RW, flags); - void refcnt_inc () const { ++refcnt; } - void refcnt_dec () const { --refcnt; } + MTH void refcnt_inc () const { ++refcnt; } + MTH void refcnt_dec () const { --refcnt; } // check wether the object has died and destroy - void refcnt_chk () { if (refcnt <= 0) do_check (); } + MTH void refcnt_chk () { if (refcnt <= 0) do_check (); } // destroy the object unless it was already destroyed // this politely asks everybody interested the reduce // the refcount to 0 as soon as possible. - void destroy (); + MTH void destroy (); // return wether an object was destroyed already - bool destroyed () const { return flags & F_DESTROYED; } + MTH bool destroyed () const { return flags & F_DESTROYED; } virtual void gather_callbacks (AV *&callbacks, event_type event) const; @@ -249,7 +251,7 @@ *p = '\n'; } - void put (keyword k, const char *v) + void put (keyword k, const char *v = 0) { put_string (k, v); } @@ -324,7 +326,7 @@ put (k, (T *)v); } - bool save (const char *filename); + bool save (const char *path); char *as_string (); // like strdup operator bool () { return !!av; } @@ -340,10 +342,11 @@ AV *av; // perl part char *line; // current beginning of line char *last_keyword, *last_value; + const char *name; operator bool () { return !!text; } - object_thawer (const char *filename = 0); + object_thawer (const char *path = 0); object_thawer (const char *data, AV *perlav); ~object_thawer (); @@ -385,6 +388,19 @@ static int nready () { return CORO_NREADY; } static int cede () { return CORO_CEDE ; } + + static int cede_counter; + + static void cede_every (int count) + { + if (++cede_counter >= count) + { + cede_counter = 0; + + if (coroapi::nready ()) + coroapi::cede (); + } + } }; struct watcher_base