Ejemplo n.º 1
0
        public IPersistent Get(int oid)
        {
            while (true)
            {
                lock (this)
                {
                    Entry[] tab   = table;
                    int     index = (oid & 0x7FFFFFFF) % tab.Length;
                    for (Entry e = tab[index], prev = null; e != null; prev = e, e = e.next)
                    {
                        if (e.oid == oid)
                        {
                            IPersistent obj = (IPersistent)e.oref.Target;
                            if (obj == null)
                            {
                                if (e.dirty > 0)
                                {
                                    goto waitFinalization;
                                }
                            }
                            else
                            {
                                if (obj.IsDeleted())
                                {
                                    if (prev != null)
                                    {
                                        prev.next = e.next;
                                    }
                                    else
                                    {
                                        tab[index] = e.next;
                                    }
                                    unpinObject(e);
                                    e.clear();
                                    count -= 1;
                                    return(null);
                                }
                                pinObject(e, obj);
                            }
                            return(obj);
                        }
                    }
                    return(null);
                }
waitFinalization:
                GC.WaitForPendingFinalizers();
            }
        }