Example #1
0
 public unsafe static SSSPCell LoadSSSPCell(this Trinity.Storage.LocalMemoryStorage storage, long CellID)
 {
     using (var cell = new SSSPCell_Accessor(CellID, ActionOnCellNotFound.ThrowException))
     {
         SSSPCell ret = cell;
         ret.CellID = CellID;
         return(ret);
     }
 }
Example #2
0
 public unsafe CellAccessorAction(Action <SSSPCell_Accessor> action)
 {
     CellType = CellType.SSSPCell;
     _action  = (cellID, long_ptr, CellEntryIndex) =>
     {
         SSSPCell_Accessor accessor = new SSSPCell_Accessor((byte *)long_ptr);
         accessor.CellID         = cellID;
         accessor.CellEntryIndex = CellEntryIndex;
         action(accessor);
     };
 }
Example #3
0
 public unsafe SSSPCell(long cell_id, AccessorBuffer buffer)
 {
     byte[] cellContent = buffer.Buffer;
     fixed(byte *ptr = cellContent)
     {
         using (var accessor = new SSSPCell_Accessor(ptr))
         {
             this.distance = accessor.distance; this.parent = accessor.parent; this.neighbors = accessor.neighbors;
         }
         CellID = cell_id;
     }
 }
Example #4
0
 public unsafe static SSSPCell LoadSSSPCell(this Trinity.Storage.MemoryCloud storage, long CellID)
 {
     byte[] content = Global.CloudStorage.LoadCell(CellID);
     fixed(byte *ptr = content)
     {
         using (var cell = new SSSPCell_Accessor(ptr))
         {
             SSSPCell ret = cell;
             ret.CellID = CellID;
             return(ret);
         }
     }
 }
Example #5
0
        internal static SSSPCell_Accessor New(long CellID, ActionOnCellNotFound action)
        {
            if (accessorPool == null)
            {
                accessorPool = new Stack <SSSPCell_Accessor>();
            }
            SSSPCell_Accessor ret = null;

            if (accessorPool.Count != 0)
            {
                ret = accessorPool.Pop();
                int tmp;
                ret.CellPtr = Global.LocalStorage.GetLockedUnsafeCellLocation(CellID, out tmp, out ret.CellEntryIndex);
                if (ret.CellPtr == null)
                {
                    if (action == ActionOnCellNotFound.ThrowException)
                    {
                        throw new CellNotFoundException("Cell with ID=" + CellID + " not found!");
                    }
                    else if (action == ActionOnCellNotFound.CreateNew)
                    {
                        int    size;
                        byte[] defaultContent = construct(CellID);
                        ret.CellPtr = Global.LocalStorage.AddOrUse(CellID, out size, out ret.CellEntryIndex, defaultContent, (ushort)CellType.SSSPCell);
                    }
                    else
                    {
                        accessorPool.Push(ret);
                        return(null);
                    }
                }
                ret.CellID = CellID;
                return(ret);
            }
            ret = new SSSPCell_Accessor(CellID, action);
            if (ret.CellID == -1 && CellID != -1)
            {
                return(null);
            }
            else
            {
                return(ret);
            }
        }
Example #6
0
 public unsafe static SSSPCell_Accessor UseSSSPCell(this Trinity.Storage.LocalMemoryStorage storage, long CellID, ActionOnCellNotFound action)
 {
     return(SSSPCell_Accessor.New(CellID, action));
 }
Example #7
0
        public static bool operator ==(SSSPCell_Accessor a, SSSPCell b)
        {
            SSSPCell_Accessor bb = b;

            return(a == bb);
        }