Package org.jctools.channels.proxy
Class ProxyChannelFactory
- java.lang.Object
-
- org.jctools.channels.proxy.ProxyChannelFactory
-
public class ProxyChannelFactory extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private static boolean
DEBUG
private static int
LOCALS_INDEX_THIS
The index of the 'this' object in instance methodsprivate static int
START_TYPE_ID
-
Constructor Summary
Constructors Constructor Description ProxyChannelFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static void
consumerReferenceArrayIndex(org.objectweb.asm.MethodVisitor methodVisitor, int localIndexOfROffset, java.lang.Class<? extends ProxyChannelRingBuffer> backendType)
static <E> ProxyChannel<E>
createMpscProxy(int capacity, java.lang.Class<E> iFace, WaitStrategy waitStrategy)
Create a default multi producer single consumer (MPSC) proxy channel.static <E> ProxyChannel<E>
createProxy(int capacity, java.lang.Class<E> iFace, WaitStrategy waitStrategy, java.lang.Class<? extends ProxyChannelRingBuffer> backendType)
Create a proxy channel using a user supplied back end.static <E> ProxyChannel<E>
createSpscProxy(int capacity, java.lang.Class<E> iFace, WaitStrategy waitStrategy)
Create a default single producer single consumer (SPSC) proxy channel.private static java.lang.Class<?>
findExisting(java.lang.String generatedName, java.lang.Class<?> iFace)
private static java.util.List<java.lang.reflect.Method>
findRelevantMethods(java.lang.Class<?> iFace)
private static void
getReference(org.objectweb.asm.MethodVisitor methodVisitor, java.lang.Class<?> parameterType, int localIndexOfArrayReferenceBaseIndex, int arrayReferenceBaseIndexDelta, java.lang.Class<? extends ProxyChannelRingBuffer> backendType)
private static int
getUnsafe(org.objectweb.asm.MethodVisitor methodVisitor, java.lang.Class<?> parameterType, int localIndexOfROffset, int rOffsetDelta)
private static void
implementBridgeMethod(org.objectweb.asm.ClassVisitor classVisitor, java.lang.String generatedName, java.lang.String methodName, java.lang.Class<?> returnType, java.lang.Class<?>... parameterTypes)
private static void
implementConstructor(org.objectweb.asm.ClassVisitor classVisitor, java.lang.Class<? extends ProxyChannelRingBuffer> parentType, java.lang.String generatedName, int primitiveMessageSize, int referenceMessageSize)
private static void
implementInstanceFields(org.objectweb.asm.ClassVisitor classVisitor)
private static void
implementProcess(org.objectweb.asm.ClassVisitor classVisitor, java.lang.Class<? extends ProxyChannelRingBuffer> backendType, java.util.List<java.lang.reflect.Method> methods, java.lang.Class<?> iFace, java.lang.String generatedName)
private static void
implementProxy(org.objectweb.asm.ClassVisitor classVisitor, java.lang.Class<?> iFace, java.lang.String generatedName)
private static void
implementProxyInstance(org.objectweb.asm.ClassVisitor classVisitor, java.lang.Class<?> iFace, java.lang.String generatedName)
private static void
implementUserMethod(java.lang.reflect.Method method, org.objectweb.asm.ClassVisitor classVisitor, int type, java.lang.String generatedName, java.lang.Class<? extends ProxyChannelRingBuffer> backendType)
private static void
implementUserMethods(org.objectweb.asm.ClassWriter classWriter, java.util.List<java.lang.reflect.Method> relevantMethods, java.lang.String generatedName, java.lang.Class<? extends ProxyChannelRingBuffer> backendType)
private static <E> ProxyChannel<E>
instantiate(java.lang.Class<?> proxy, int capacity, WaitStrategy waitStrategy)
private static void
loadLocalIndexAndApplyDelta(org.objectweb.asm.MethodVisitor methodVisitor, int localVariableIndex, long delta)
private static void
loadUnsafe(org.objectweb.asm.MethodVisitor methodVisitor)
private static void
loadWOffset(org.objectweb.asm.MethodVisitor methodVisitor, java.lang.Class<?> parameterType, int baseOffset, long wOffsetDelta)
private static java.lang.String
methodDescriptor(java.lang.Class<?> returnType, java.lang.Class<?>... parameterTypes)
private static int
parameterTypeUnsafe(org.objectweb.asm.MethodVisitor methodVisitor, java.lang.Class<?> parameterType, boolean write)
private static int
primitiveMemorySize(java.lang.Class<?> type)
private static void
printClassBytes(byte[] byteCode)
private static void
producerReferenceArrayIndex(org.objectweb.asm.MethodVisitor methodVisitor, int localIndexOfWOffset, java.lang.Class<? extends ProxyChannelRingBuffer> backendType)
private static void
putReference(org.objectweb.asm.MethodVisitor methodVisitor, java.lang.Class<?> parameterType, int localIndexOfArrayReferenceBaseIndex, int arrayReferenceBaseIndexDelta, int varOffset, java.lang.Class<? extends ProxyChannelRingBuffer> backendType)
private static int
putUnsafe(org.objectweb.asm.MethodVisitor methodVisitor, java.lang.Class<?> parameterType, int wOffset, int wOffsetDelta, int varOffset)
private static void
readAcquire(org.objectweb.asm.MethodVisitor methodVisitor, java.lang.Class<? extends ProxyChannelRingBuffer> backendType)
private static void
readReference(org.objectweb.asm.MethodVisitor methodVisitor, java.lang.Class<? extends ProxyChannelRingBuffer> backend)
private static void
readRelease(org.objectweb.asm.MethodVisitor methodVisitor, int wOffset, java.lang.Class<? extends ProxyChannelRingBuffer> backendType)
static long
writeAcquireWithWaitStrategy(ProxyChannelRingBuffer channelBackend, WaitStrategy waitStrategy)
private static void
writeAcquireWithWaitStrategy(org.objectweb.asm.MethodVisitor methodVisitor, java.lang.String generatedName, java.lang.Class<? extends ProxyChannelRingBuffer> backendType)
private static void
writeReference(org.objectweb.asm.MethodVisitor methodVisitor, java.lang.Class<? extends ProxyChannelRingBuffer> backendType)
private static void
writeRelease(org.objectweb.asm.MethodVisitor methodVisitor, int wOffset, int type, java.lang.Class<? extends ProxyChannelRingBuffer> backendType)
-
-
-
Field Detail
-
START_TYPE_ID
private static final int START_TYPE_ID
- See Also:
- Constant Field Values
-
LOCALS_INDEX_THIS
private static final int LOCALS_INDEX_THIS
The index of the 'this' object in instance methods- See Also:
- Constant Field Values
-
DEBUG
private static final boolean DEBUG
-
-
Method Detail
-
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, java.lang.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 supportiFace
- Interface the proxy must implementwaitStrategy
- 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, java.lang.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 supportiFace
- Interface the proxy must implementwaitStrategy
- 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, java.lang.Class<E> iFace, WaitStrategy waitStrategy, java.lang.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 supportiFace
- Interface the proxy must implementwaitStrategy
- A wait strategy to be invoked when the backing data structure is fullbackendType
- 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, java.util.List<java.lang.reflect.Method> relevantMethods, java.lang.String generatedName, java.lang.Class<? extends ProxyChannelRingBuffer> backendType)
-
findRelevantMethods
private static java.util.List<java.lang.reflect.Method> findRelevantMethods(java.lang.Class<?> iFace)
-
findExisting
private static java.lang.Class<?> findExisting(java.lang.String generatedName, java.lang.Class<?> iFace)
-
instantiate
private static <E> ProxyChannel<E> instantiate(java.lang.Class<?> proxy, int capacity, WaitStrategy waitStrategy)
-
implementProcess
private static void implementProcess(org.objectweb.asm.ClassVisitor classVisitor, java.lang.Class<? extends ProxyChannelRingBuffer> backendType, java.util.List<java.lang.reflect.Method> methods, java.lang.Class<?> iFace, java.lang.String generatedName)
-
implementInstanceFields
private static void implementInstanceFields(org.objectweb.asm.ClassVisitor classVisitor)
-
implementConstructor
private static void implementConstructor(org.objectweb.asm.ClassVisitor classVisitor, java.lang.Class<? extends ProxyChannelRingBuffer> parentType, java.lang.String generatedName, int primitiveMessageSize, int referenceMessageSize)
-
implementProxyInstance
private static void implementProxyInstance(org.objectweb.asm.ClassVisitor classVisitor, java.lang.Class<?> iFace, java.lang.String generatedName)
-
implementProxy
private static void implementProxy(org.objectweb.asm.ClassVisitor classVisitor, java.lang.Class<?> iFace, java.lang.String generatedName)
-
implementBridgeMethod
private static void implementBridgeMethod(org.objectweb.asm.ClassVisitor classVisitor, java.lang.String generatedName, java.lang.String methodName, java.lang.Class<?> returnType, java.lang.Class<?>... parameterTypes)
-
implementUserMethod
private static void implementUserMethod(java.lang.reflect.Method method, org.objectweb.asm.ClassVisitor classVisitor, int type, java.lang.String generatedName, java.lang.Class<? extends ProxyChannelRingBuffer> backendType)
-
producerReferenceArrayIndex
private static void producerReferenceArrayIndex(org.objectweb.asm.MethodVisitor methodVisitor, int localIndexOfWOffset, java.lang.Class<? extends ProxyChannelRingBuffer> backendType)
-
consumerReferenceArrayIndex
private static void consumerReferenceArrayIndex(org.objectweb.asm.MethodVisitor methodVisitor, int localIndexOfROffset, java.lang.Class<? extends ProxyChannelRingBuffer> backendType)
-
writeAcquireWithWaitStrategy
private static void writeAcquireWithWaitStrategy(org.objectweb.asm.MethodVisitor methodVisitor, java.lang.String generatedName, java.lang.Class<? extends ProxyChannelRingBuffer> backendType)
-
writeRelease
private static void writeRelease(org.objectweb.asm.MethodVisitor methodVisitor, int wOffset, int type, java.lang.Class<? extends ProxyChannelRingBuffer> backendType)
-
readAcquire
private static void readAcquire(org.objectweb.asm.MethodVisitor methodVisitor, java.lang.Class<? extends ProxyChannelRingBuffer> backendType)
-
readRelease
private static void readRelease(org.objectweb.asm.MethodVisitor methodVisitor, int wOffset, java.lang.Class<? extends ProxyChannelRingBuffer> backendType)
-
getUnsafe
private static int getUnsafe(org.objectweb.asm.MethodVisitor methodVisitor, java.lang.Class<?> parameterType, int localIndexOfROffset, int rOffsetDelta)
-
putUnsafe
private static int putUnsafe(org.objectweb.asm.MethodVisitor methodVisitor, java.lang.Class<?> parameterType, int wOffset, int wOffsetDelta, int varOffset)
-
getReference
private static void getReference(org.objectweb.asm.MethodVisitor methodVisitor, java.lang.Class<?> parameterType, int localIndexOfArrayReferenceBaseIndex, int arrayReferenceBaseIndexDelta, java.lang.Class<? extends ProxyChannelRingBuffer> backendType)
-
putReference
private static void putReference(org.objectweb.asm.MethodVisitor methodVisitor, java.lang.Class<?> parameterType, int localIndexOfArrayReferenceBaseIndex, int arrayReferenceBaseIndexDelta, int varOffset, java.lang.Class<? extends ProxyChannelRingBuffer> backendType)
-
loadUnsafe
private static void loadUnsafe(org.objectweb.asm.MethodVisitor methodVisitor)
-
loadWOffset
private static void loadWOffset(org.objectweb.asm.MethodVisitor methodVisitor, java.lang.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, java.lang.Class<?> parameterType, boolean write)
-
writeReference
private static void writeReference(org.objectweb.asm.MethodVisitor methodVisitor, java.lang.Class<? extends ProxyChannelRingBuffer> backendType)
-
readReference
private static void readReference(org.objectweb.asm.MethodVisitor methodVisitor, java.lang.Class<? extends ProxyChannelRingBuffer> backend)
-
primitiveMemorySize
private static int primitiveMemorySize(java.lang.Class<?> type)
-
methodDescriptor
private static java.lang.String methodDescriptor(java.lang.Class<?> returnType, java.lang.Class<?>... parameterTypes)
-
-