This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import groovyx.gpars.dataflow.DataFlowQueue | |
import groovyx.gpars.dataflow.operator.DataFlowPoisson | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin:'groovy' | |
apply plugin:'idea' | |
repositories { mavenCentral() } | |
dependencies { | |
groovy 'org.codehaus.groovy:groovy-all:1.8.2' | |
} | |
task makeDirs(description:'make all dirs for project setup') << { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// a git pre-receive hook | |
// that automatically merges all pushes to feature branches | |
// into a dedicated continuous-integration (ci) branch. | |
// Since we cannot merge in a bare repo, we work on a temporary clone. | |
// Dierk Koenig | |
def ciBranch = 'master' | |
def mergeName = 'merge' | |
def hereDirPath = new File('.').canonicalPath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright 2012-2013 Canoo Engineering AG. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import groovyx.gpars.dataflow.KanbanFlow | |
import groovyx.gpars.dataflow.KanbanLink | |
import groovyx.gpars.dataflow.KanbanTray | |
import groovyx.gpars.dataflow.ProcessingNode | |
import static groovyx.gpars.dataflow.ProcessingNode.node | |
/* | |
A massively parallel game of life with KanbanFlow. | |
Every cell signals to all neighbors when it has a new value. | |
Every cell waits for signals from all its neighbors. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import groovy.transform.Immutable | |
import groovyx.gpars.dataflow.KanbanFlow | |
import groovyx.gpars.dataflow.KanbanLink | |
import groovyx.gpars.dataflow.KanbanTray | |
import groovyx.gpars.dataflow.ProcessingNode | |
import static groovyx.gpars.dataflow.ProcessingNode.node | |
/* | |
For a general introduction see https://gist.github.com/Dierk/6365780. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Making the Frege language available. Compiler and Runtime is all in one jar. | |
To be completed. | |
@author Dierk Koenig | |
*/ | |
apply plugin:'java' | |
def frege_version = '3.21.190' | |
def qualifier = 'g714a7cc' | |
def frege_jar = file(System.properties.'user.home'+"/.frege/home/frege-${frege_version}.jar") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.canoo | |
import javax.script.* | |
//Get the Frege Script Engine | |
final frege = new ScriptEngineManager().getEngineByName("frege") | |
//Evaluate an expression | |
println frege.eval('show $ take 10 [2,4..]') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait HasId { | |
long id | |
} | |
trait HasVersion { | |
long version | |
} | |
trait Persistent { | |
boolean save() { println "saving ${this.dump()}" } | |
} | |
trait Entity implements Persistent, HasId, HasVersion { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// has all methods of List | |
trait ListLike { | |
@Delegate List linkedList = new LinkedList() | |
} | |
// stores anything but exposes only Strings | |
class StringList implements ListLike { | |
String get(int index) { linkedList.get(index).toString() } | |
} |
OlderNewer