Class DedicatedExecutorProtocolHolder
java.lang.Object
pt.unl.fct.di.novasys.babel2.core.AbstractBabelProtocolHolder
pt.unl.fct.di.novasys.babel2.core.DedicatedExecutorProtocolHolder
- All Implemented Interfaces:
BabelProtocolHolder
A
BabelProtocolHolder implementation that runs the protocol on a dedicated,
single-threaded executor using a lock-free MpscArrayQueue.
This holder provides isolated execution for CPU-intensive protocols or protocols that must not share execution threads with others.
-
Field Summary
Fields inherited from class AbstractBabelProtocolHolder
protocol -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDedicatedExecutorProtocolHolder(BabelProtocol protocol, Set<ProtocolExtension<? extends BabelProtocol>> extensions, ExecutorService executor, int maxQueueCapacity) Constructs a holder with a dedicated executor and bounded event queue. -
Method Summary
Modifier and TypeMethodDescriptionvoiddeliverEvent(BabelEvent event) Enqueues or delivers an event to the underlying protocol.Methods inherited from class AbstractBabelProtocolHolder
createHandler, eventHandlers, getInnerProtocol, holdsProtocol, interestedEvents, interestedInMessages, interestedOutFailedMessages, interestedOutSuccessMessages, invokeHandler, invokeHandler, invokeHandler, invokeHandlerModifier and TypeMethodDescription<T> TcreateHandler(Method method, MethodHandles.Lookup lookup, Class<? extends BabelProtocol> protocolClass, Class<T> handlerInterface, String handlerMethodName, Class<?>[] erasedParamType, Class<?>[] actualParamType) Creates a typed functional-interface handler for the given method usingLambdaMetafactory.Map<Class<? extends ProtocolEvent>, EventHandler<? extends ProtocolEvent>> Returns the mapping of handledProtocolEventclasses to their compiled event handlers.Returns the underlying protocol instance managed by this holder.booleanholdsProtocol(Class<? extends BabelProtocol> protocolClass) Returns whether this holder manages a protocol that is an instance of or assignable to the given protocol class.Set<Class<? extends ProtocolEvent>> Returns the set ofProtocolEventclasses that this protocol has registered interest in.Set<Class<? extends BabelMessage>> Returns the set ofBabelMessageclasses that this protocol is interested in receiving.Set<Class<? extends BabelMessage>> Returns the set ofBabelMessageclasses for which this protocol handles delivery failure.Set<Class<? extends BabelMessage>> Returns the set ofBabelMessageclasses for which this protocol handles successful delivery.protected voidinvokeHandler(MessageInEvent event) Invokes the compiled handler for the specified inbound message event.protected voidInvokes the compiled handler for the specified outbound message failure event.protected voidInvokes the compiled handler for the specified outbound message success event.protected voidinvokeHandler(ProtocolEvent event) Invokes the compiled handler for the specified protocol event.
-
Constructor Details
-
DedicatedExecutorProtocolHolder
protected DedicatedExecutorProtocolHolder(BabelProtocol protocol, Set<ProtocolExtension<? extends BabelProtocol>> extensions, ExecutorService executor, int maxQueueCapacity) Constructs a holder with a dedicated executor and bounded event queue.- Parameters:
protocol- the protocol instance to manageextensions- the protocol extensions configured for this protocolexecutor- the dedicated executor service for this protocolmaxQueueCapacity- the maximum number of pending events allowed in the queue
-
-
Method Details
-
deliverEvent
Description copied from interface:BabelProtocolHolderEnqueues or delivers an event to the underlying protocol.- Parameters:
event- the event to deliver
-