Package org.jctools.channels.proxy
Class ProxyChannelFactory
java.lang.Object
org.jctools.channels.proxy.ProxyChannelFactory
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final boolean
private static final int
The index of the 'this' object in instance methodsprivate static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
consumerReferenceArrayIndex
(org.objectweb.asm.MethodVisitor methodVisitor, int localIndexOfROffset, Class<? extends ProxyChannelRingBuffer> backendType) static <E> ProxyChannel
<E> createMpscProxy
(int capacity, Class<E> iFace, WaitStrategy waitStrategy) Create a default multi producer single consumer (MPSC) proxy channel.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.static <E> ProxyChannel
<E> createSpscProxy
(int capacity, Class<E> iFace, WaitStrategy waitStrategy) Create a default single producer single consumer (SPSC) proxy channel.private static Class
<?> findExisting
(String generatedName, Class<?> iFace) findRelevantMethods
(Class<?> iFace) private static void
getReference
(org.objectweb.asm.MethodVisitor methodVisitor, Class<?> parameterType, int localIndexOfArrayReferenceBaseIndex, int arrayReferenceBaseIndexDelta, Class<? extends ProxyChannelRingBuffer> backendType) private static int
getUnsafe
(org.objectweb.asm.MethodVisitor methodVisitor, Class<?> parameterType, int localIndexOfROffset, int rOffsetDelta) private static void
implementBridgeMethod
(org.objectweb.asm.ClassVisitor classVisitor, String generatedName, String methodName, Class<?> returnType, Class<?>... parameterTypes) private static void
implementConstructor
(org.objectweb.asm.ClassVisitor classVisitor, Class<? extends ProxyChannelRingBuffer> parentType, String generatedName, int primitiveMessageSize, int referenceMessageSize) private static void
implementInstanceFields
(org.objectweb.asm.ClassVisitor classVisitor) private static void
implementProcess
(org.objectweb.asm.ClassVisitor classVisitor, Class<? extends ProxyChannelRingBuffer> backendType, List<Method> methods, Class<?> iFace, String generatedName) private static void
implementProxy
(org.objectweb.asm.ClassVisitor classVisitor, Class<?> iFace, String generatedName) private static void
implementProxyInstance
(org.objectweb.asm.ClassVisitor classVisitor, Class<?> iFace, String generatedName) private static void
implementUserMethod
(Method method, org.objectweb.asm.ClassVisitor classVisitor, int type, String generatedName, Class<? extends ProxyChannelRingBuffer> backendType) private static void
implementUserMethods
(org.objectweb.asm.ClassWriter classWriter, List<Method> relevantMethods, String generatedName, Class<? extends ProxyChannelRingBuffer> backendType) private static <E> ProxyChannel
<E> instantiate
(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, Class<?> parameterType, int baseOffset, long wOffsetDelta) private static String
methodDescriptor
(Class<?> returnType, Class<?>... parameterTypes) private static int
parameterTypeUnsafe
(org.objectweb.asm.MethodVisitor methodVisitor, Class<?> parameterType, boolean write) private static int
primitiveMemorySize
(Class<?> type) private static void
printClassBytes
(byte[] byteCode) private static void
producerReferenceArrayIndex
(org.objectweb.asm.MethodVisitor methodVisitor, int localIndexOfWOffset, Class<? extends ProxyChannelRingBuffer> backendType) private static void
putReference
(org.objectweb.asm.MethodVisitor methodVisitor, Class<?> parameterType, int localIndexOfArrayReferenceBaseIndex, int arrayReferenceBaseIndexDelta, int varOffset, Class<? extends ProxyChannelRingBuffer> backendType) private static int
putUnsafe
(org.objectweb.asm.MethodVisitor methodVisitor, Class<?> parameterType, int wOffset, int wOffsetDelta, int varOffset) private static void
readAcquire
(org.objectweb.asm.MethodVisitor methodVisitor, Class<? extends ProxyChannelRingBuffer> backendType) private static void
readReference
(org.objectweb.asm.MethodVisitor methodVisitor, Class<? extends ProxyChannelRingBuffer> backend) private static void
readRelease
(org.objectweb.asm.MethodVisitor methodVisitor, int wOffset, Class<? extends ProxyChannelRingBuffer> backendType) static long
writeAcquireWithWaitStrategy
(ProxyChannelRingBuffer channelBackend, WaitStrategy waitStrategy) private static void
writeAcquireWithWaitStrategy
(org.objectweb.asm.MethodVisitor methodVisitor, String generatedName, Class<? extends ProxyChannelRingBuffer> backendType) private static void
writeReference
(org.objectweb.asm.MethodVisitor methodVisitor, Class<? extends ProxyChannelRingBuffer> backendType) private static void
writeRelease
(org.objectweb.asm.MethodVisitor methodVisitor, int wOffset, int type, Class<? extends ProxyChannelRingBuffer> backendType)
-
Field Details
-
START_TYPE_ID
private static final int START_TYPE_ID- See Also:
-
LOCALS_INDEX_THIS
private static final int LOCALS_INDEX_THISThe 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 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, 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, 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 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, List<Method> relevantMethods, String generatedName, Class<? extends ProxyChannelRingBuffer> backendType) -
findRelevantMethods
-
findExisting
-
instantiate
private static <E> ProxyChannel<E> instantiate(Class<?> proxy, int capacity, WaitStrategy waitStrategy) -
implementProcess
-
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
-
implementProxy
-
implementBridgeMethod
-
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
-
methodDescriptor
-