Class ProductLoader

java.lang.Object
org.variantsync.boosting.product.ProductLoader
All Implemented Interfaces:
Iterator<Variant>

public class ProductLoader extends Object implements Iterator<Variant>
A class that implements an Iterator for loading products using multiple threads. This class takes a list of ProductLoadTask objects and a number of threads to use for loading the products. It then creates a thread pool with the specified number of threads and submits tasks to load products.
  • Constructor Details

    • ProductLoader

      public ProductLoader(List<ProductLoadTask> loadTasks, int nThreads)
      Constructs a ProductLoader with the specified list of load tasks and number of threads.
      Parameters:
      loadTasks - a list of ProductLoadTask objects representing the tasks to load products
      nThreads - the number of threads to use for loading products
  • Method Details

    • hasNext

      public boolean hasNext()
      Checks if there are more products to load.
      Specified by:
      hasNext in interface Iterator<Variant>
      Returns:
      true if there are more products to load, false otherwise
    • next

      public Variant next()
      Loads the next product using a thread from the thread pool.
      Specified by:
      next in interface Iterator<Variant>
      Returns:
      the next product to load
      Throws:
      RuntimeException - if an error occurs while loading the product