Talk:CoroutineScheduler

From Unify Community Wiki
Revision as of 04:24, 18 April 2011 by Bunny83 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

RemoveCoroutine

You have some redundancy in your RemoveCoroutine function. If you're not the head of the list (you are not the first) there have to be a previous node. Also if you're the first node you have to check if there's a successor and you have to set it to null as well. Otherwise it will exist until the list is empty.

So it could be simplified to:

<javascript>

 if (first == coroutine) { // remove first
     first = coroutine.listNext;
 } else { // we have a predecessor
     coroutine.listPrevious.listNext = coroutine.listNext;
 }
 if (coroutine.listNext != null) { // we have a successor
     coroutine.listNext.listPrevious = coroutine.listPrevious;
 }

</javascript>

However, really nice example, i think that will help beginners a lot. Too bad you can't upvote in the wiki ;) --Bunny83 18:40, 17 April 2011 (PDT)

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox