‣ InfoPtree | ( info class ) |
‣ InfoRecursiveIterator | ( info class ) |
‣ 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
generated by GAPDoc2HTML