Skip to content

Instantly share code, notes, and snippets.

View vaclav's full-sized avatar

Václav Pech vaclav

View GitHub Profile

Keybase proof

I hereby claim:

  • I am vaclav on github.
  • I am venca (https://keybase.io/venca) on keybase.
  • I have a public key ASAtl7g3Tqkoou5UY0vN2jE0UsAVX5PK7O6mgJHli3Dg-go

To claim this, I am signing this object:

@vaclav
vaclav / gist:75da6dde2050ffc09dbf
Created November 2, 2014 16:54
GPars - producer / up-to-ten consumers
import groovyx.gpars.dataflow.DataflowQueue
import static groovyx.gpars.dataflow.Dataflow.task
import static groovyx.gpars.dataflow.Dataflow.operator
/**
* A simple producer consumer sample showing use of the DataflowQueue class.
*/
def words = ['Groovy', 'fantastic', 'concurrency', 'fun', 'enjoy', 'safe', 'GPars', 'data', 'flow']
final def buffer = new DataflowQueue()
@vaclav
vaclav / gist:8bd831f81ba9c38106b8
Created November 1, 2014 20:34
GPars - producer-2 consumers
import groovyx.gpars.dataflow.DataflowQueue
import static groovyx.gpars.dataflow.Dataflow.task
/**
* A simple producer consumer sample showing use of the DataflowQueue class.
*/
def words = ['Groovy', 'fantastic', 'concurrency', 'fun', 'enjoy', 'safe', 'GPars', 'data', 'flow']
final def buffer = new DataflowQueue()
task {
@vaclav
vaclav / SafeThreadStarter
Created September 10, 2014 12:42
Illustrates use of Groovy traits to safely start a thread through the run() method instead of the proper start() method
trait SafeStarter {
private boolean started = false
public void run() {
if (!started) {
this.start()
started = true
}
super.run()
}
}
@vaclav
vaclav / piapprox-alternative.groovy
Last active August 29, 2015 13:59
Inspired by https://gist.github.com/timyates/10474027, just using static and dynamic dispatch actors instead
import groovy.transform.*
import groovyx.gpars.actor.*
import groovyx.gpars.group.*
@Immutable class Calculate {}
@Immutable class Work { int start, nrOfElements }
@Immutable class Result { double value }
@Immutable class PiApproximation { double pi ; long duration }
double calculatePiFor( int start, int nrOfElements ) {
Hello GPars community,
I am currently writting my bachelor thesis "Comparison of Concurrency Frameworks for the JVM"
at the university of ulm in Germany. Since one qualitative property of an framework is also its
community and support I decided to check that by myself by asking this questions. This Gist repo
is thought to gather your ideas and oppinions about GPars relating to the questions below in oder
to improve my comparison. Feel free to answer as controversial as you want :). Just add the points
you miss. Thank you very much.
1. Why do you prefer GPars over other frameworks such as Akka?
@vaclav
vaclav / GPars Questions
Last active December 20, 2015 00:18 — forked from TommiK/GPars Questions
Hello GPars community,
I am currently writting my bachelor thesis "Comparison of Concurrency Frameworks for the JVM"
at the university of ulm in Germany. Since one qualitative property of an framework is also its
community and support I decided to check that by myself by asking this questions. This Gist repo
is thought to gather your ideas and oppinions about GPars relating to the questions below in oder
to improve my comparison. Feel free to answer as controversial as you want :). Just add the points
you miss. Thank you very much.
1. Why do you prefer GPars over other frameworks such as Akka?
@vaclav
vaclav / StatelessActorDemo
Created November 5, 2010 05:58
Using GPars actors in Java
import groovy.lang.Closure;
import groovyx.gpars.actor.DynamicDispatchActor;
public class StatelessActorDemo {
public static void main(String[] args) throws InterruptedException {
final MyStatelessActor actor = new MyStatelessActor();
actor.start();
actor.send("Hello");
actor.sendAndWait(10);