Skip to content

Instantly share code, notes, and snippets.

View macg33zr's full-sized avatar
💭
Working part time...

Bill Dennis macg33zr

💭
Working part time...
View GitHub Profile
@macg33zr
macg33zr / KanbanDemo.groovy
Created March 20, 2012 09:57 — forked from Dierk/KanbanDemo.groovy
Classic concurrent producer-consumer problem with using a kanban system to avoid buffer overflows when consumers are slow
import groovyx.gpars.dataflow.DataflowQueue
import groovyx.gpars.dataflow.operator.PoisonPill
import static groovyx.gpars.dataflow.Dataflow.operator
import java.util.concurrent.atomic.AtomicInteger
def upstream = new DataflowQueue() // empty trays travel back upstream to the producer
def downstream = new DataflowQueue() // trays with products travel to the consumer downstream
def prodWiring = [inputs: [upstream], outputs: [downstream], maxForks: 3 ] // maxForks is optional
def consWiring = [inputs: [downstream], outputs: [upstream], maxForks: 3 ] // maxForks is optional