Пример #1
0
 private void ParseGarbage(string line, int trackOn)
 {
     if (trackOn == -1)
     {
         if (line.Trim() != "")
         {
             Garbage.Add(line);
         }
     }
     else
     {
         m_Tracks[trackOn].AddGarbage(line);
     }
 }
Пример #2
0
    public static void Collect()
    {
        if (Garbage.clothesline != null)
        {
            return;                                      // there's only one GC, which never ends
        }
        Garbage.clothesline = Garbage.myOwnHook;         // can't use static initializer cause of ordering issues
        hook previous = myOwnHook;

        for (hook current = myOwnHook; ProgramStillRunning || myOwnHook.next != myOwnHook; previous = current, current = current.next)
        {
            if (previous == myOwnHook || current == myOwnHook)
            {   // never operate on the myownhook--myownhook.next border, because that's where new items are added async-ly
                cycle++;
                continue;
            }
            if (current.destroyMe != null)
            {
                // call the dying object's destructor. If it doesn't want to be destroyed, (and it's young), skip it for now.
                if (!current.destroyMe.apoptosis())
                {
                    if (cycle - current.age < 20)
                    {
                        continue;
                    }
                }
                // loop through all ref values held by the class and move them to the clothesline
                foreach (var property in current.destroyMe.allRefProperties())
                {
                    Garbage.Add(current.destroyMe.ValueOfProperty(property));
                    //current.destroyMe.property = null;
                }
                // now remove this class from its hook
                memory.dealloc(current.destroyMe);
                current.destroyMe = null;
            }
            // now that the object is gone, remove its hook from the clothesline
            lock (semaphore)
                previous.next = current.next;
            current.next = null;
            // and destroy the hook itself
            memory.dealloc(current);
            // Set Current back to something on the clothesline.
            current = previous;
        }
    }