pack8() public static method

public static pack8 ( byte arr, int offs, long val ) : void
arr byte
offs int
val long
return void
        public virtual void Write(long pos, byte[] buf)
        {
            for (int i = 0; i < sockets.Length; i++)
            {
                while (sockets[i] != null)
                {
                    try
                    {
                        Bytes.pack8(txBuf, 0, pos);
                        Array.Copy(buf, 0, txBuf, 8, buf.Length);
                        sockets[i].Send(txBuf);
                        if (!ack || pos != 0 || sockets[i].Receive(rcBuf) == 1)
                        {
                            break;
                        }
                    }
                    catch (SocketException) { }

                    sockets[i] = null;
                    nHosts    -= 1;
                    if (HandleError(hosts[i]))
                    {
                        connect(i);
                    }
                    else
                    {
                        break;
                    }
                }
            }
            file.Write(pos, buf);
        }
Esempio n. 2
0
        internal void pack(Page pg, int i)
        {
            byte[] dst = pg.data;
            switch (key.type)
            {
            case ClassDescriptor.FieldType.tpBoolean:
            case ClassDescriptor.FieldType.tpSByte:
            case ClassDescriptor.FieldType.tpByte:
                dst[OldBtreePage.firstKeyOffs + i] = (byte)key.ival;
                break;

            case ClassDescriptor.FieldType.tpShort:
            case ClassDescriptor.FieldType.tpUShort:
            case ClassDescriptor.FieldType.tpChar:
                Bytes.pack2(dst, OldBtreePage.firstKeyOffs + i * 2, (short)key.ival);
                break;

            case ClassDescriptor.FieldType.tpInt:
            case ClassDescriptor.FieldType.tpUInt:
            case ClassDescriptor.FieldType.tpEnum:
            case ClassDescriptor.FieldType.tpObject:
            case ClassDescriptor.FieldType.tpOid:
                Bytes.pack4(dst, OldBtreePage.firstKeyOffs + i * 4, key.ival);
                break;

            case ClassDescriptor.FieldType.tpLong:
            case ClassDescriptor.FieldType.tpULong:
            case ClassDescriptor.FieldType.tpDate:
                Bytes.pack8(dst, OldBtreePage.firstKeyOffs + i * 8, key.lval);
                break;

            case ClassDescriptor.FieldType.tpFloat:
                Bytes.packF4(dst, OldBtreePage.firstKeyOffs + i * 4, (float)key.dval);
                break;

            case ClassDescriptor.FieldType.tpDouble:
                Bytes.packF8(dst, OldBtreePage.firstKeyOffs + i * 8, key.dval);
                break;

            case ClassDescriptor.FieldType.tpDecimal:
                Bytes.packDecimal(dst, OldBtreePage.firstKeyOffs + i * 16, key.dec);
                break;

            case ClassDescriptor.FieldType.tpGuid:
                Bytes.packGuid(dst, OldBtreePage.firstKeyOffs + i * 16, key.guid);
                break;


            default:
                Debug.Assert(false, "Invalid type");
                break;
            }
            Bytes.pack4(dst, OldBtreePage.firstKeyOffs + (OldBtreePage.maxItems - i - 1) * 4, oid);
        }
 public virtual void Close()
 {
     file.Close();
     Bytes.pack8(txBuf, 0, -1);
     for (int i = 0; i < sockets.Length; i++)
     {
         if (sockets[i] != null)
         {
             try
             {
                 sockets[i].Send(txBuf);
                 sockets[i].Close();
             }
             catch (SocketException) { }
         }
     }
 }
        public override void Write(long pos, byte[] buf)
        {
            file.Write(pos, buf);
            for (int i = 0; i < sockets.Length; i++)
            {
                if (sockets[i] != null)
                {
                    byte[] data = new byte[8 + buf.Length];
                    Bytes.pack8(data, 0, pos);
                    Array.Copy(buf, 0, data, 8, buf.Length);
                    Parcel p = new Parcel();
                    p.data = data;
                    p.pos  = pos;
                    p.host = i;

                    lock (async)
                    {
                        buffered += data.Length;
                        while (buffered > asyncBufSize)
                        {
                            Monitor.Wait(async);
                        }
                    }

                    lock (go)
                    {
                        if (head == null)
                        {
                            head = tail = p;
                        }
                        else
                        {
                            tail = tail.next = p;
                        }
                        Monitor.Pulse(go);
                    }
                }
            }
        }
Esempio n. 5
0
 public int packI8(int offs, long val)
 {
     extend(offs + 8);
     Bytes.pack8(arr, offs, val);
     return offs + 8;
 }