com.koushikdutta.async.http.libcore
Class Memory

java.lang.Object
  extended by com.koushikdutta.async.http.libcore.Memory

public final class Memory
extends java.lang.Object

Unsafe access to memory.


Method Summary
static void memmove(java.lang.Object dstObject, int dstOffset, java.lang.Object srcObject, int srcOffset, long byteCount)
          Copies 'byteCount' bytes from the source to the destination.
static byte peekByte(int address)
           
static void peekByteArray(int address, byte[] dst, int dstOffset, int byteCount)
           
static void peekCharArray(int address, char[] dst, int dstOffset, int charCount, boolean swap)
           
static void peekDoubleArray(int address, double[] dst, int dstOffset, int doubleCount, boolean swap)
           
static void peekFloatArray(int address, float[] dst, int dstOffset, int floatCount, boolean swap)
           
static int peekInt(byte[] src, int offset, java.nio.ByteOrder order)
           
static int peekInt(int address, boolean swap)
           
static void peekIntArray(int address, int[] dst, int dstOffset, int intCount, boolean swap)
           
static long peekLong(byte[] src, int offset, java.nio.ByteOrder order)
           
static long peekLong(int address, boolean swap)
           
static void peekLongArray(int address, long[] dst, int dstOffset, int longCount, boolean swap)
           
static short peekShort(byte[] src, int offset, java.nio.ByteOrder order)
           
static short peekShort(int address, boolean swap)
           
static void peekShortArray(int address, short[] dst, int dstOffset, int shortCount, boolean swap)
           
static void pokeByte(int address, byte value)
           
static void pokeByteArray(int address, byte[] src, int offset, int count)
           
static void pokeCharArray(int address, char[] src, int offset, int count, boolean swap)
           
static void pokeDoubleArray(int address, double[] src, int offset, int count, boolean swap)
           
static void pokeFloatArray(int address, float[] src, int offset, int count, boolean swap)
           
static void pokeInt(byte[] dst, int offset, int value, java.nio.ByteOrder order)
           
static void pokeInt(int address, int value, boolean swap)
           
static void pokeIntArray(int address, int[] src, int offset, int count, boolean swap)
           
static void pokeLong(byte[] dst, int offset, long value, java.nio.ByteOrder order)
           
static void pokeLong(int address, long value, boolean swap)
           
static void pokeLongArray(int address, long[] src, int offset, int count, boolean swap)
           
static void pokeShort(byte[] dst, int offset, short value, java.nio.ByteOrder order)
           
static void pokeShort(int address, short value, boolean swap)
           
static void pokeShortArray(int address, short[] src, int offset, int count, boolean swap)
           
static void unsafeBulkGet(java.lang.Object dst, int dstOffset, int byteCount, byte[] src, int srcOffset, int sizeofElements, boolean swap)
          Used to optimize nio heap buffer bulk get operations.
static void unsafeBulkPut(byte[] dst, int dstOffset, int byteCount, java.lang.Object src, int srcOffset, int sizeofElements, boolean swap)
          Used to optimize nio heap buffer bulk put operations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

unsafeBulkGet

public static void unsafeBulkGet(java.lang.Object dst,
                                 int dstOffset,
                                 int byteCount,
                                 byte[] src,
                                 int srcOffset,
                                 int sizeofElements,
                                 boolean swap)
Used to optimize nio heap buffer bulk get operations. 'dst' must be a primitive array. 'dstOffset' is measured in units of 'sizeofElements' bytes.


unsafeBulkPut

public static void unsafeBulkPut(byte[] dst,
                                 int dstOffset,
                                 int byteCount,
                                 java.lang.Object src,
                                 int srcOffset,
                                 int sizeofElements,
                                 boolean swap)
Used to optimize nio heap buffer bulk put operations. 'src' must be a primitive array. 'srcOffset' is measured in units of 'sizeofElements' bytes.


peekInt

public static int peekInt(byte[] src,
                          int offset,
                          java.nio.ByteOrder order)

peekLong

public static long peekLong(byte[] src,
                            int offset,
                            java.nio.ByteOrder order)

peekShort

public static short peekShort(byte[] src,
                              int offset,
                              java.nio.ByteOrder order)

pokeInt

public static void pokeInt(byte[] dst,
                           int offset,
                           int value,
                           java.nio.ByteOrder order)

pokeLong

public static void pokeLong(byte[] dst,
                            int offset,
                            long value,
                            java.nio.ByteOrder order)

pokeShort

public static void pokeShort(byte[] dst,
                             int offset,
                             short value,
                             java.nio.ByteOrder order)

memmove

public static void memmove(java.lang.Object dstObject,
                           int dstOffset,
                           java.lang.Object srcObject,
                           int srcOffset,
                           long byteCount)
Copies 'byteCount' bytes from the source to the destination. The objects are either instances of DirectByteBuffer or byte[]. The offsets in the byte[] case must include the Buffer.arrayOffset if the array came from a Buffer.array call. We could make this private and provide the four type-safe variants, but then ByteBuffer.put(ByteBuffer) would need to work out which to call based on whether the source and destination buffers are direct or not.


peekByte

public static byte peekByte(int address)

peekInt

public static int peekInt(int address,
                          boolean swap)

peekLong

public static long peekLong(int address,
                            boolean swap)

peekShort

public static short peekShort(int address,
                              boolean swap)

peekByteArray

public static void peekByteArray(int address,
                                 byte[] dst,
                                 int dstOffset,
                                 int byteCount)

peekCharArray

public static void peekCharArray(int address,
                                 char[] dst,
                                 int dstOffset,
                                 int charCount,
                                 boolean swap)

peekDoubleArray

public static void peekDoubleArray(int address,
                                   double[] dst,
                                   int dstOffset,
                                   int doubleCount,
                                   boolean swap)

peekFloatArray

public static void peekFloatArray(int address,
                                  float[] dst,
                                  int dstOffset,
                                  int floatCount,
                                  boolean swap)

peekIntArray

public static void peekIntArray(int address,
                                int[] dst,
                                int dstOffset,
                                int intCount,
                                boolean swap)

peekLongArray

public static void peekLongArray(int address,
                                 long[] dst,
                                 int dstOffset,
                                 int longCount,
                                 boolean swap)

peekShortArray

public static void peekShortArray(int address,
                                  short[] dst,
                                  int dstOffset,
                                  int shortCount,
                                  boolean swap)

pokeByte

public static void pokeByte(int address,
                            byte value)

pokeInt

public static void pokeInt(int address,
                           int value,
                           boolean swap)

pokeLong

public static void pokeLong(int address,
                            long value,
                            boolean swap)

pokeShort

public static void pokeShort(int address,
                             short value,
                             boolean swap)

pokeByteArray

public static void pokeByteArray(int address,
                                 byte[] src,
                                 int offset,
                                 int count)

pokeCharArray

public static void pokeCharArray(int address,
                                 char[] src,
                                 int offset,
                                 int count,
                                 boolean swap)

pokeDoubleArray

public static void pokeDoubleArray(int address,
                                   double[] src,
                                   int offset,
                                   int count,
                                   boolean swap)

pokeFloatArray

public static void pokeFloatArray(int address,
                                  float[] src,
                                  int offset,
                                  int count,
                                  boolean swap)

pokeIntArray

public static void pokeIntArray(int address,
                                int[] src,
                                int offset,
                                int count,
                                boolean swap)

pokeLongArray

public static void pokeLongArray(int address,
                                 long[] src,
                                 int offset,
                                 int count,
                                 boolean swap)

pokeShortArray

public static void pokeShortArray(int address,
                                  short[] src,
                                  int offset,
                                  int count,
                                  boolean swap)