Class SharedExecutorProtocolHolder
java.lang.Object
pt.unl.fct.di.novasys.babel2.core.AbstractBabelProtocolHolder
pt.unl.fct.di.novasys.babel2.core.SharedExecutorProtocolHolder
- All Implemented Interfaces:
BabelProtocolHolder
A
BabelProtocolHolder implementation that schedules event queue draining on a
shared thread pool executor.
Multiple protocols can share the same executor, with each protocol maintaining its own
lock-free MpscArrayQueue. Protocols cooperate by yielding execution after
processing a configurable number of events per turn (batch size), preventing starvation.
-
Field Summary
Fields inherited from class AbstractBabelProtocolHolder
protocol -
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.
-
Method Details
-
deliverEvent
Description copied from interface:BabelProtocolHolderEnqueues or delivers an event to the underlying protocol.- Parameters:
event- the event to deliver
-