Class Hoarde<T extends Actor>

java.lang.Object
org.nustaq.kontraktor.util.Hoarde<T>

public class Hoarde<T extends Actor> extends Object
Created by ruedi on 07.09.14. a utility class allowing to address/manage multiple actors of same type
  • Constructor Details

    • Hoarde

      public Hoarde(int numActors, Class<T> actor)
      create a hoarde with each actor having a dedicated thread
      Parameters:
      numActors -
      actor -
    • Hoarde

      public Hoarde(int numActors, Class<T> actor, Scheduler sched)
      create a hoarde scheduled on given scheduler
      Parameters:
      numActors -
      actor -
      sched -
  • Method Details

    • map

      public <X> IPromise<T>[] map(BiFunction<T,Integer,IPromise<X>> init)
    • each

      public Hoarde<T> each(Consumer<T> tocall)
      iterate over each actor and execute tocall. E.g. hoarde.each( actor -> actor.init() )
      Parameters:
      tocall -
      Returns:
    • each

      public Hoarde<T> each(BiConsumer<T,Integer> init)
      same as other each but with index
      Parameters:
      init -
      Returns:
    • ordered

      public IPromise ordered(Function<T,IPromise> toCall)
      calls given function round robin. typical use: hoarde.ordered( actor -> actor.decode(byte[]) ).onResult( decodedObj -> businesslogic(decodedObj) ); after
      Parameters:
      toCall -
      Returns:
    • getSize

      public int getSize()
    • getActor

      public T getActor(int i)