Class CoordinatorThread

java.lang.Object
modelarium.multithreading.CoordinatorThread
All Implemented Interfaces:
Runnable

public class CoordinatorThread extends Object implements Runnable
Coordinator thread responsible for managing synchronised access to shared simulation state between multiple worker threads in a parallel simulation.

This class listens to the request queue and uses CoordinatorRequestHandler to respond to agent/environment-related queries or updates.

  • Constructor Summary

    Constructors
    Constructor
    Description
    CoordinatorThread(String name, Config config, Environment environment, modelarium.multithreading.requestresponse.RequestResponseController requestResponseController, modelarium.clock.Clock sharedClock)
    Constructs the coordinator thread with required references.
    CoordinatorThread(String name, Config config, Environment environment, modelarium.multithreading.requestresponse.RequestResponseController requestResponseController, modelarium.clock.Clock sharedClock, AgentSet predefinedGlobalAgentSet, Map<String,String> agentThreadMap)
    Constructs the coordinator thread with required references.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    run()
    Main execution loop for the coordinator thread.
    void
    Signals the coordinator thread to stop processing and terminate.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CoordinatorThread

      public CoordinatorThread(String name, Config config, Environment environment, modelarium.multithreading.requestresponse.RequestResponseController requestResponseController, modelarium.clock.Clock sharedClock)
      Constructs the coordinator thread with required references.
      Parameters:
      name - the thread name or ID
      config - global model settings
      environment - the shared simulation environment
      requestResponseController - the controller managing request/response queues
      sharedClock - the clock used to keep a track of time passing in the model
    • CoordinatorThread

      public CoordinatorThread(String name, Config config, Environment environment, modelarium.multithreading.requestresponse.RequestResponseController requestResponseController, modelarium.clock.Clock sharedClock, AgentSet predefinedGlobalAgentSet, Map<String,String> agentThreadMap)
      Constructs the coordinator thread with required references.
      Parameters:
      name - the thread name or ID
      config - global model settings
      environment - the shared simulation environment
      requestResponseController - the controller managing request/response queues
      sharedClock - the clock used to keep a track of time passing in the model
      predefinedGlobalAgentSet - the pre-defined agent set instance to use as the global agent set
      agentThreadMap - the map from agent name to the worker thread containing that agent
  • Method Details

    • shutdown

      public void shutdown()
      Signals the coordinator thread to stop processing and terminate.
    • run

      public void run()
      Main execution loop for the coordinator thread.

      Continuously listens for requests from worker threads and processes them.

      Specified by:
      run in interface Runnable