Package org.nustaq.kontraktor.util
Class Hoarde<T extends Actor>
java.lang.Object
org.nustaq.kontraktor.util.Hoarde<T>
Created by ruedi on 07.09.14.
a utility class allowing to address/manage multiple actors of same type
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioneach(BiConsumer<T, Integer> init) same as other each but with indexiterate over each actor and execute tocall.getActor(int i) intgetSize()map(BiFunction<T, Integer, IPromise<X>> init) calls given function round robin. typical use: hoarde.ordered( actor -> actor.decode(byte[]) ).onResult( decodedObj -> businesslogic(decodedObj) ); after
-
Constructor Details
-
Hoarde
create a hoarde with each actor having a dedicated thread- Parameters:
numActors-actor-
-
Hoarde
create a hoarde scheduled on given scheduler- Parameters:
numActors-actor-sched-
-
-
Method Details
-
map
-
each
iterate over each actor and execute tocall. E.g. hoarde.each( actor -> actor.init() )- Parameters:
tocall-- Returns:
-
each
same as other each but with index- Parameters:
init-- Returns:
-
ordered
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
-