Parallel Coder

Caboose.erl


caboose.erl is a simple erlang version of GenStage in Elixir.
Let us see a sample run.


21> caboose:start().
 Caboose is a demand driven chain of processes. 
 a <- b <- c 
 a -> c -> c 
 a is a caboose, b is a car, c is an engine 
 requests for data flow from engine to caboose 
 data flows from caboose to engine 
 all a, b and c have a tank that holds outputs 
 all a, b and c have a data list that hold inputs  
 all a, b and c have a function 
 but the function is not applied in a caboose 
 the function turns inputs into outputs 
{list,is,[<0.159.0>,<0.160.0>,<0.161.0>],in,engine} 
{tank,is,[1,2,3,4,5,6,7,8,9,10,11,12],in,a} 
{function,is,#Fun,in,b} 
{function,is,#Fun,in,c} 
[<0.159.0>,<0.160.0>,<0.161.0>]
{function,is,#Fun,in,a} 
{boss,is,<0.161.0>,in,b} 
{request,is,4,in,c} 
{boss,is,<0.160.0>,in,a} 
{source,is,<0.159.0>,in,b} 
{source,is,<0.160.0>,in,c} 
{label,is,caboose,in,a} 
{watch,is,true,in,c} 
{request,is,4,in,b} 
{engine,is,<0.158.0>,in,a} 
{output,data,is,[],in,c} 
{request,is,4,in,b} 
{request,is,4,in,a} 
{tank,is,[2,4,6,8,10,12,14,16,18,20,22,24],in,b} 
{tank,is,[4,8,12,16,20,24,28,32,36,40,44,48],in,c} 
{output,data,is,[8,16,24,32,40,48,56,64,72,80,88,96],in,c} 
{request,is,4,in,a}