… | |
… | |
164 | } |
164 | } |
165 | |
165 | |
166 | void |
166 | void |
167 | attachable::check_mortals () |
167 | attachable::check_mortals () |
168 | { |
168 | { |
169 | for (int i = 0; i < mortals.size (); ) |
169 | static int i = 0; |
|
|
170 | |
|
|
171 | for (;;) |
170 | { |
172 | { |
|
|
173 | if (i >= mortals.size ()) |
|
|
174 | { |
|
|
175 | i = 0; |
|
|
176 | |
|
|
177 | if (mortals.size () > 1000) |
|
|
178 | fprintf (stderr, "mortal queue size (%d) exceeds 1000.\n", mortals.size ()); |
|
|
179 | |
|
|
180 | break; |
|
|
181 | } |
|
|
182 | |
171 | attachable *obj = mortals [i]; |
183 | attachable *obj = mortals [i]; |
172 | |
184 | |
173 | obj->refcnt_chk (); // unborrow from perl, if necessary |
185 | obj->refcnt_chk (); // unborrow from perl, if necessary |
174 | |
186 | |
175 | if (obj->refcnt || obj->self) |
187 | if (obj->refcnt > 0 || obj->self) |
176 | { |
188 | { |
177 | #if 0 |
189 | //printf ("%p rc %d\n", obj, obj->refcnt_cnt ());//D |
178 | if (mortals.size() > 5)fprintf (stderr, "%d delaying %d:%p:%s %d (self %p:%d)\n", time(0),i, obj, typeid (*obj).name (), |
|
|
179 | obj->refcnt, obj->self, obj->self ? SvREFCNT(obj->self): - 1);//D |
|
|
180 | #endif |
|
|
181 | |
|
|
182 | ++i; // further delay freeing |
190 | ++i; // further delay freeing |
|
|
191 | |
|
|
192 | if (!(i & 0x3ff)) |
|
|
193 | break; |
183 | }//D |
194 | } |
184 | else |
195 | else |
185 | { |
196 | { |
186 | //Dfprintf (stderr, "deleteing %d:%p:%s\n", i, obj,typeid (*obj).name ());//D |
|
|
187 | mortals.erase (i); |
197 | mortals.erase (i); |
188 | delete obj; |
198 | delete obj; |
189 | } |
199 | } |
190 | } |
200 | } |
191 | } |
201 | } |
… | |
… | |
895 | void |
905 | void |
896 | iw::alloc () |
906 | iw::alloc () |
897 | { |
907 | { |
898 | pe = GEventAPI->new_idle (0, 0); |
908 | pe = GEventAPI->new_idle (0, 0); |
899 | |
909 | |
|
|
910 | WaREENTRANT_off (pe); |
900 | pe->base.callback = (void *)iw_dispatch; |
911 | pe->base.callback = (void *)iw_dispatch; |
901 | pe->base.ext_data = (void *)this; |
912 | pe->base.ext_data = (void *)this; |
902 | } |
913 | } |
903 | |
914 | |
904 | static void iow_dispatch (pe_event *ev) |
915 | static void iow_dispatch (pe_event *ev) |
… | |
… | |
910 | void |
921 | void |
911 | iow::alloc () |
922 | iow::alloc () |
912 | { |
923 | { |
913 | pe = GEventAPI->new_io (0, 0); |
924 | pe = GEventAPI->new_io (0, 0); |
914 | |
925 | |
|
|
926 | WaREENTRANT_off (pe); |
915 | pe->base.callback = (void *)iow_dispatch; |
927 | pe->base.callback = (void *)iow_dispatch; |
916 | pe->base.ext_data = (void *)this; |
928 | pe->base.ext_data = (void *)this; |
917 | |
929 | |
918 | pe->fd = -1; |
930 | pe->fd = -1; |
919 | pe->poll = 0; |
931 | pe->poll = 0; |