Class RequestResponseController

java.lang.Object
modelarium.multithreading.requestresponse.RequestResponseController

public class RequestResponseController extends Object
Central controller for managing the request and response queues used in synchronised, multithreaded agent-based simulations.

This class acts as a message broker between worker threads and the coordinator thread, ensuring safe, concurrent access to both queues via BlockingQueue.

Each thread can obtain a thread-safe RequestResponseInterface instance tied to its name for interacting with the controller.

  • Constructor Details

    • RequestResponseController

      public RequestResponseController(ModelSettings settings)
      Constructs a new request-response controller for coordinating simulation threads.
      Parameters:
      settings - the shared model settings used across threads
  • Method Details

    • getRequestQueue

      public BlockingQueue<Request> getRequestQueue()
      Returns the shared request queue.
      Returns:
      the request queue
    • getResponseQueue

      public BlockingQueue<Response> getResponseQueue()
      Returns the shared response queue.
      Returns:
      the response queue
    • getInterface

      public RequestResponseInterface getInterface(String name)
      Creates and returns a RequestResponseInterface for a given thread name. This interface wraps queue operations and helps manage request lifecycles.
      Parameters:
      name - the name of the requesting thread
      Returns:
      a new RequestResponseInterface instance for the caller