Class MorkEventPublisher

java.lang.Object
es.urjc.etsii.grafo.events.MorkEventPublisher
All Implemented Interfaces:
org.springframework.beans.factory.DisposableBean

@Component public class MorkEventPublisher extends Object implements org.springframework.beans.factory.DisposableBean
Single async boundary between solver threads and event consumers.
  • Constructor Details

    • MorkEventPublisher

      @Autowired public MorkEventPublisher(org.springframework.beans.factory.ObjectProvider<MorkEventListener> listeners, org.springframework.messaging.simp.SimpMessagingTemplate messagingTemplate, InMemoryEventLog eventLog)
      Build event publisher, creating the single dispatcher thread.
      Parameters:
      listeners - backend event listeners provided by Spring
      messagingTemplate - websocket messaging template
      eventLog - in-memory replay log
    • MorkEventPublisher

      public MorkEventPublisher(Iterable<MorkEventListener> listeners, org.springframework.messaging.simp.SimpMessagingTemplate messagingTemplate, InMemoryEventLog eventLog)
      Build an event publisher with an explicit listener collection.
      Parameters:
      listeners - backend event listeners
      messagingTemplate - websocket messaging template
      eventLog - in-memory replay log
  • Method Details

    • publish

      public void publish(MorkEvent event)
      Publish an event without executing listeners on the caller thread.
      Parameters:
      event - event payload
    • publishFinalAndBeginDraining

      public void publishFinalAndBeginDraining(MorkEvent finalEvent)
      Atomically accept the terminal event and enter the draining state. No external publisher can insert an event after the terminal event.
      Parameters:
      finalEvent - terminal event payload
    • mute

      Temporarily mute event publishing. Intended for warm-up or other unmeasured work.
      Returns:
      scope that restores the previous mute depth when closed
    • isMuted

      public boolean isMuted()
      Check whether events are muted.
      Returns:
      true if events are muted
    • beginDraining

      public void beginDraining()
      Atomically start draining without waiting for it to finish. New external publications are rejected as soon as this method returns.
    • drainAndStop

      public void drainAndStop()
      Reject new external events, drain every accepted event (including events recursively published by listeners), and stop the dispatcher.
    • destroy

      public void destroy()
      Shut down the dispatcher when the Spring context closes.
      Specified by:
      destroy in interface org.springframework.beans.factory.DisposableBean