Provides logical grouping for actors, agents and dataflow tasks and operators. Each group has an underlying thread pool, which will perform actions on behalf of the users belonging to the group. {@code Actors} created through the {@code DefaultPGroup.actor} method will automatically belong to the groupthrough which they were created, just like agents created through the {@code agent} or {@code fairAgent}methods or dataflow tasks and operators created through the {@code task} or {@code operator} methods.Uses a pool of non-daemon threads. The {@code DefaultPGroup} class implements the {@code Pool} interfacethrough {@code @Delegate}.
def group = new DefaultPGroup() group.resize 1 def actor = group.actor { react { message -> println message } }.start() actor.send 'Hi!' . . . group.shutdown()
Otherwise, if constructing {@code Actors} directly through their constructors, the {@code AbstractPooledActor.parallelGroup} property, which defaults to the {@code Actors.defaultActorPGroup}, can be set before the actor is started.
def group = new DefaultPGroup() def actor = new MyActor() actor.parallelGroup = group actor.start() . . . group.shutdown()
@author Vaclav Pech