Goto Chapter: Top 1 2 3 4 Ind
 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 

2 Parallely evaluate recursive iterators
 2.1 Info Classes
 2.2 Parallely evaluate recursive iterators

2 Parallely evaluate recursive iterators

2.1 Info Classes

2.1-1 InfoPtree
‣ InfoPtree( info class )

2.1-2 InfoRecursiveIterator
‣ InfoRecursiveIterator( info class )

2.2 Parallely evaluate recursive iterators

2.2-1 ParallelyEvaluateRecursiveIterator
‣ ParallelyEvaluateRecursiveIterator( state, n, iter, ch )( function )

Returns: a record

Parallely evaluate the recursive iterator iter using n workers (threads). Save the internal state of computations in the given (usually empty) record state, for the user to be able to trace the internal state of computations. The produced leaves are then written to the channel ch. The procedure returns a record containing the component shutdown, which is a no-argument function the user can call to terminate the parallel evaluation.

This example enumerates all full binary trees with 9 leaves. The number is the sixth Catalan number.

gap> ReadPackage( "ParallelizedIterators", "examples/CatalanIterator.g" );
true
gap> state := rec( );
rec(  )
gap> threads := 2;
2
gap> n := 9;
9
gap> riter := IteratorCatalanTree( [[ 1 .. n ]], [[ 1 ]] );
<iterator>
gap> ch := CreateChannel( 10000 );;
gap> scheduler := ParallelyEvaluateRecursiveIterator( state, threads, riter, ch );
rec( shutdown := function(  ) ... end )
gap> i := 0;
0
gap> while true do l:=ReceiveChannel( ch ); if l=fail then break; fi; i:=i+1; od;
gap> i;
1430
 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 
Goto Chapter: Top 1 2 3 4 Ind

generated by GAPDoc2HTML