Interface ConcurrentRequestsHandler

All Known Implementing Classes:
DefaultConcurrentRequestsHandler

public interface ConcurrentRequestsHandler
Interface for concurrent requests handler used to limit the maximum requests which can run in parallel. Depending on usage, we could limit the number of concurrent requests per connection or per connector.
  • Method Details

    • runWhenPermitted

      Thread runWhenPermitted(Runnable request, ThreadCollection threadCollection, long timeoutMillis, long requestId, com.seeq.utilities.ManualResetEvent requestThreadStartedEvent)
      Ensures that only a specific number of requests will be executed in parallel.
      Parameters:
      request - Concurrent task to be executed
      threadCollection - Thread collection used to spawn a new thread for the request
      timeoutMillis - Amount of time to wait for request completion
      requestId - Request identifier
      requestThreadStartedEvent - Manual reset event which will be set after the thread of the request is started. The thread may be waiting for permission to run its job, but we are sure the thread is started when the event is set.
      Returns:
      the thread of the executed request
    • getMaxConcurrentRequests

      int getMaxConcurrentRequests()
      Returns:
      the maximum number of concurrent requests. When this limit is exceeded, any call of runWhenPermitted will block the execution of the request until an execution slot is available.
    • getRegisteredRequestsCount

      int getRegisteredRequestsCount()
      Returns:
      the number of registered requests. May be different than the number of requests currently executed.