… | |
… | |
174 | MTH void refcnt_inc () const { ++refcnt; } |
174 | MTH void refcnt_inc () const { ++refcnt; } |
175 | MTH void refcnt_dec () const { --refcnt; } |
175 | MTH void refcnt_dec () const { --refcnt; } |
176 | |
176 | |
177 | MTH int refcnt_cnt () const; |
177 | MTH int refcnt_cnt () const; |
178 | // check wether the object has died and destroy |
178 | // check wether the object has died and destroy |
179 | MTH void refcnt_chk () { if (refcnt <= 0) do_check (); } |
179 | MTH void refcnt_chk () { if (expect_false (refcnt <= 0)) do_check (); } |
180 | |
180 | |
181 | // destroy the object unless it was already destroyed |
181 | // destroy the object unless it was already destroyed |
182 | // this politely asks everybody interested the reduce |
182 | // this politely asks everybody interested the reduce |
183 | // the refcount to 0 as soon as possible. |
183 | // the refcount to 0 as soon as possible. |
184 | MTH void destroy (); |
184 | MTH void destroy (); |
… | |
… | |
348 | } |
348 | } |
349 | |
349 | |
350 | template<typename T> |
350 | template<typename T> |
351 | void put (keyword k, const T *v) |
351 | void put (keyword k, const T *v) |
352 | { |
352 | { |
353 | if (v) |
|
|
354 | put (k, v->name); |
|
|
355 | else |
|
|
356 | put (k, (const char *)0); |
353 | put (k, v ? &v->name : (const char *)0); |
357 | } |
354 | } |
358 | |
355 | |
359 | template<typename T> |
356 | template<typename T> |
360 | void put (keyword k, const refptr<T> &v) |
357 | void put (keyword k, const refptr<T> &v) |
361 | { |
358 | { |
… | |
… | |
444 | { |
441 | { |
445 | if (expect_false (++cede_counter >= count)) |
442 | if (expect_false (++cede_counter >= count)) |
446 | do_cede_every (); |
443 | do_cede_every (); |
447 | } |
444 | } |
448 | |
445 | |
449 | static void cede_to_tick () |
446 | static bool cede_to_tick () |
450 | { |
447 | { |
451 | if (expect_false (time () >= next_cede)) |
448 | if (expect_true (time () < next_cede)) |
|
|
449 | return false; |
|
|
450 | |
452 | do_cede_to_tick (); |
451 | do_cede_to_tick (); |
|
|
452 | return true; |
453 | } |
453 | } |
454 | |
454 | |
455 | static void cede_to_tick_every (int count) |
455 | static bool cede_to_tick_every (int count) |
456 | { |
456 | { |
457 | if (expect_false (++cede_counter >= count)) |
457 | if (expect_true (++cede_counter < count)) |
|
|
458 | return false; |
|
|
459 | |
458 | cede_to_tick (); |
460 | return cede_to_tick (); |
459 | } |
461 | } |
460 | |
462 | |
461 | static void wait_for_tick (); |
463 | static void wait_for_tick (); |
462 | static void wait_for_tick_begin (); |
464 | static void wait_for_tick_begin (); |
463 | }; |
465 | }; |