Class ProxyChannelFactory

java.lang.Object
org.jctools.channels.proxy.ProxyChannelFactory

public class ProxyChannelFactory extends Object
  • Field Details

    • START_TYPE_ID

      private static final int START_TYPE_ID
      See Also:
    • LOCALS_INDEX_THIS

      private static final int LOCALS_INDEX_THIS
      The index of the 'this' object in instance methods
      See Also:
    • DEBUG

      private static final boolean DEBUG
  • Constructor Details

    • ProxyChannelFactory

      public ProxyChannelFactory()
  • Method Details

    • printClassBytes

      private static void printClassBytes(byte[] byteCode)
    • writeAcquireWithWaitStrategy

      public static long writeAcquireWithWaitStrategy(ProxyChannelRingBuffer channelBackend, WaitStrategy waitStrategy)
    • createSpscProxy

      public static <E> ProxyChannel<E> createSpscProxy(int capacity, Class<E> iFace, WaitStrategy waitStrategy)
      Create a default single producer single consumer (SPSC) proxy channel.
      Parameters:
      capacity - The minimum capacity for unprocessed invocations the channel should support
      iFace - Interface the proxy must implement
      waitStrategy - A wait strategy to be invoked when the backing data structure is full
      Returns:
      A proxy channel instance
    • createMpscProxy

      public static <E> ProxyChannel<E> createMpscProxy(int capacity, Class<E> iFace, WaitStrategy waitStrategy)
      Create a default multi producer single consumer (MPSC) proxy channel.
      Parameters:
      capacity - The minimum capacity for unprocessed invocations the channel should support
      iFace - Interface the proxy must implement
      waitStrategy - A wait strategy to be invoked when the backing data structure is full
      Returns:
      A proxy channel instance
    • createProxy

      public static <E> ProxyChannel<E> createProxy(int capacity, Class<E> iFace, WaitStrategy waitStrategy, Class<? extends ProxyChannelRingBuffer> backendType)
      Create a proxy channel using a user supplied back end.
      Parameters:
      capacity - The minimum capacity for unprocessed invocations the channel should support
      iFace - Interface the proxy must implement
      waitStrategy - A wait strategy to be invoked when the backing data structure is full
      backendType - The back end type, the proxy will inherit from this channel type. The back end type must define a constructor with signature: (int capacity, int primitiveMessageSize, int referenceMessageSize)
      Returns:
      A proxy channel instance
    • implementUserMethods

      private static void implementUserMethods(org.objectweb.asm.ClassWriter classWriter, List<Method> relevantMethods, String generatedName, Class<? extends ProxyChannelRingBuffer> backendType)
    • findRelevantMethods

      private static List<Method> findRelevantMethods(Class<?> iFace)
    • findExisting

      private static Class<?> findExisting(String generatedName, Class<?> iFace)
    • instantiate

      private static <E> ProxyChannel<E> instantiate(Class<?> proxy, int capacity, WaitStrategy waitStrategy)
    • implementProcess

      private static void implementProcess(org.objectweb.asm.ClassVisitor classVisitor, Class<? extends ProxyChannelRingBuffer> backendType, List<Method> methods, Class<?> iFace, String generatedName)
    • implementInstanceFields

      private static void implementInstanceFields(org.objectweb.asm.ClassVisitor classVisitor)
    • implementConstructor

      private static void implementConstructor(org.objectweb.asm.ClassVisitor classVisitor, Class<? extends ProxyChannelRingBuffer> parentType, String generatedName, int primitiveMessageSize, int referenceMessageSize)
    • implementProxyInstance

      private static void implementProxyInstance(org.objectweb.asm.ClassVisitor classVisitor, Class<?> iFace, String generatedName)
    • implementProxy

      private static void implementProxy(org.objectweb.asm.ClassVisitor classVisitor, Class<?> iFace, String generatedName)
    • implementBridgeMethod

      private static void implementBridgeMethod(org.objectweb.asm.ClassVisitor classVisitor, String generatedName, String methodName, Class<?> returnType, Class<?>... parameterTypes)
    • implementUserMethod

      private static void implementUserMethod(Method method, org.objectweb.asm.ClassVisitor classVisitor, int type, String generatedName, Class<? extends ProxyChannelRingBuffer> backendType)
    • producerReferenceArrayIndex

      private static void producerReferenceArrayIndex(org.objectweb.asm.MethodVisitor methodVisitor, int localIndexOfWOffset, Class<? extends ProxyChannelRingBuffer> backendType)
    • consumerReferenceArrayIndex

      private static void consumerReferenceArrayIndex(org.objectweb.asm.MethodVisitor methodVisitor, int localIndexOfROffset, Class<? extends ProxyChannelRingBuffer> backendType)
    • writeAcquireWithWaitStrategy

      private static void writeAcquireWithWaitStrategy(org.objectweb.asm.MethodVisitor methodVisitor, String generatedName, Class<? extends ProxyChannelRingBuffer> backendType)
    • writeRelease

      private static void writeRelease(org.objectweb.asm.MethodVisitor methodVisitor, int wOffset, int type, Class<? extends ProxyChannelRingBuffer> backendType)
    • readAcquire

      private static void readAcquire(org.objectweb.asm.MethodVisitor methodVisitor, Class<? extends ProxyChannelRingBuffer> backendType)
    • readRelease

      private static void readRelease(org.objectweb.asm.MethodVisitor methodVisitor, int wOffset, Class<? extends ProxyChannelRingBuffer> backendType)
    • getUnsafe

      private static int getUnsafe(org.objectweb.asm.MethodVisitor methodVisitor, Class<?> parameterType, int localIndexOfROffset, int rOffsetDelta)
    • putUnsafe

      private static int putUnsafe(org.objectweb.asm.MethodVisitor methodVisitor, Class<?> parameterType, int wOffset, int wOffsetDelta, int varOffset)
    • getReference

      private static void getReference(org.objectweb.asm.MethodVisitor methodVisitor, Class<?> parameterType, int localIndexOfArrayReferenceBaseIndex, int arrayReferenceBaseIndexDelta, Class<? extends ProxyChannelRingBuffer> backendType)
    • putReference

      private static void putReference(org.objectweb.asm.MethodVisitor methodVisitor, Class<?> parameterType, int localIndexOfArrayReferenceBaseIndex, int arrayReferenceBaseIndexDelta, int varOffset, Class<? extends ProxyChannelRingBuffer> backendType)
    • loadUnsafe

      private static void loadUnsafe(org.objectweb.asm.MethodVisitor methodVisitor)
    • loadWOffset

      private static void loadWOffset(org.objectweb.asm.MethodVisitor methodVisitor, Class<?> parameterType, int baseOffset, long wOffsetDelta)
    • loadLocalIndexAndApplyDelta

      private static void loadLocalIndexAndApplyDelta(org.objectweb.asm.MethodVisitor methodVisitor, int localVariableIndex, long delta)
    • parameterTypeUnsafe

      private static int parameterTypeUnsafe(org.objectweb.asm.MethodVisitor methodVisitor, Class<?> parameterType, boolean write)
    • writeReference

      private static void writeReference(org.objectweb.asm.MethodVisitor methodVisitor, Class<? extends ProxyChannelRingBuffer> backendType)
    • readReference

      private static void readReference(org.objectweb.asm.MethodVisitor methodVisitor, Class<? extends ProxyChannelRingBuffer> backend)
    • primitiveMemorySize

      private static int primitiveMemorySize(Class<?> type)
    • methodDescriptor

      private static String methodDescriptor(Class<?> returnType, Class<?>... parameterTypes)