Questions tagged [gpars]

The GPars project offers developers new intuitive and safe ways to handle Java or Groovy tasks concurrently, asynchronously, and distributed by utilizing the power of the Java platform and the flexibility of the Groovy language.

The GPars project is a concurrency framework for Groovy and Java. It provides the following abstraction layers over traditional multi-threading / parallel programming

  • Concurrent collection processing
  • Asynchronous operations
  • Fork/Join abstraction
  • Actor programming model
  • Dataflow concurrency constructs
  • Agent - an thread-safe reference to mutable state
114 questions
1
vote
1 answer

Collecting a GPars loop to a Map

I need to iterate on a List and for every item run a time-expensive operation and then collect its results to a map, something like this: List strings = ['foo', 'bar', 'baz'] Map result = strings.collectEntries { key -> …
Raibaz
  • 9,280
  • 10
  • 44
  • 65
1
vote
1 answer

How to make a Gpars Actor to read from console

I have a simple GPars actor: class ConsoleActor extends DefaultActor { protected void act() { loop { react { Msg msg -> switch (msg.type) { case MsgType.Read: …
Getodac
  • 119
  • 7
1
vote
0 answers

Is it possible to rollback all transactions made within a list of promises?

I have been following the documentation provided by Grails about promises: https://docs.grails.org/2.3.x/guide/async.html#promises I have a huge list of ids which I'm splitting up into different tasks and then calling waitAll() on the promise list.…
gjvatsalya
  • 1,129
  • 13
  • 29
1
vote
1 answer

How to get multiple async results within a given timeout with GPars?

I'd like to retrieve multiple "costly" results using parallel processing but within a specific timeout. I'm using GPars Dataflow.task but it looks like I'm missing something as the process returns only when all dataflow variable are bound. def…
Wavyx
  • 1,715
  • 2
  • 14
  • 23
1
vote
1 answer

Gpars.withPool threads eventually stops executing after iterating numerous times

Was trying to execute concurrent operations with Gpars. Gpars.withPool(6) { someList.eachParallel { println "${Thread.currentThread}" } } Initially it seems to work Thread[ForkJoinPool-1-worker-1,5,main]…
froi
  • 7,268
  • 5
  • 40
  • 78
1
vote
2 answers

Use GPars to dispatch an async task and return immediately

I would like to have a method that dispatches an async task, and returns immediately. I don't need wait for the result. I'd like something like this to work: /** * runs a job and return job id for later montoring. */ def int runJob(){ int jobId =…
Oren Yosifon
  • 897
  • 8
  • 22
1
vote
1 answer

Concurrent / parallel database queries using Groovy?

How do I implement concurrent / parallel database queries using Groovy? I want to count the number of rows in all tables from a database (select count(*) from $TABLE), and write the counts to separate files. A few of the tables have millions of…
1
vote
1 answer

GPars, GORM, Batch Upload

I have a process that needs to build a PDF document and combine it with 100s of other documents being created. I want to multiple thread this. Where I pass into the Service a list of events that I need the PDF generated and saved to the DB. The…
user2498465
  • 77
  • 10
1
vote
2 answers

Terminate existing pool when all work is done

Alright, brand new to gpars so please forgive me if this has an obvious answer. Here is my scenario. We currently have a piece of our code wrapped in a Thread.start {} block. It does this so it can send messages to an message queue in the…
Taplar
  • 24,788
  • 4
  • 22
  • 35
1
vote
1 answer

makeConcurrent dosen't seem to work in Gpars

The following program is supposed to return a list of rows which have null values. import groovyx.gpars.GParsPool import groovyx.gpars.ParallelEnhancer import org.apache.commons.lang.RandomStringUtils import groovyx.gprof.* import static…
Naresh
  • 633
  • 1
  • 6
  • 17
1
vote
1 answer

How to create a groovy actor which keeps execution unless stopped

I wanna create an Actor which keeps executing a task, then it can be stopped by an external call to stop, but got quite blocked. The actor should look the following myActor = actor { loop { react { message -> …
Ye Huang
  • 639
  • 2
  • 10
  • 21
1
vote
0 answers

Architecture for highly asynchronous events that result in database updates

I originally asked Handling database-backed async callbacks in Grails, but I've done a lot of research since then, so I am asking a more pointed question... Most recently, I tried using the Events API in the platform-core plugin, but the optimistic…
greymatter
  • 840
  • 1
  • 10
  • 25
1
vote
0 answers

Handling database-backed async callbacks in Grails

I've been working on implementing an automated trading system in Grails based on Interactive Brokers' API (brief overview here: Grails - asynchronous communication with 3rd party API) for longer than I care to admit. This is a high-frequency…
greymatter
  • 840
  • 1
  • 10
  • 25
1
vote
2 answers

Grails, Promise API and two open sessions

I am trying to clear out a collection and update it at the same time. It has children and finding the current items in the collection and deleting them asynchronously would save me a lot of time. Step 1. Find all the items in the collection. Step…
Interlated
  • 5,108
  • 6
  • 48
  • 79
1
vote
1 answer

Restrict the Number of Threads in Gpars?

I use GPars for parallel processes which do background tasks. I use the following Service to start a new background thread. To save heap memory How can I restrict the number of background threads? How can I define a thread pool of n threads which…
Michael
  • 32,527
  • 49
  • 210
  • 370