问题标签 [gpars]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
148 浏览

groovy - 演员异常

我只想在 Groovy 中的两个演员之间发送一些消息。
我收到第一条消息abc,但得到以下异常:

Actor 线程 Actor 线程 1 groovy.lang.MissingPropertyException 发生异常
:没有此类属性:act1 类:groovyx.gpars.actor.DefaultActor

这是我的代码:

0 投票
1 回答
4364 浏览

concurrency - 与 withPool 并行

我找到了一个关于如何使用的例子withPool。它说我只需要将单词添加Parallel到 Groovy 的方法中,例如collect, find, each,将其放入withPool并并行执行代码。

有没有机会检查它是否真的平行?
我尝试使用相同的代码进行基准测试,但顺序方式
和并行方式要慢得多。

0 投票
1 回答
194 浏览

groovy - 葡萄或正常进口

有什么不同吗,如何将 GPars 集成到我的项目中?
我可以做吗

或者只是(假设我的构建路径中有所有必需的 jar)

?

0 投票
2 回答
259 浏览

concurrency - GPar 的数据并行性

我在这里找到了这个例子数据并行

我觉得它有点广泛。有没有办法缩短它?
也许:

那行得通吗?
如果没有,还有其他方法吗?

0 投票
1 回答
127 浏览

concurrency - 异步函数

异步调用可组合异步函数之间有区别吗?
在第一种情况下使用async()or callAsync(),在另一种情况下使用asyncFun(). 但主要区别在哪里?

0 投票
1 回答
1286 浏览

groovy - 使用 GPar 的 Fork/Join 示例

我在这里找到了 GPars 中 fork/join 的示例:Fork/Join

它可以工作并返回正确数量的文件,但不幸的是我不明白这一行:

究竟是如何工作countchildrenResult
为什么将 a0作为参数传递给sum()

0 投票
1 回答
689 浏览

groovy - GPars: Waiting for actors to finish

I think I got this wrong from the docs.

I have two actors, XMLActor and HttpActor. XMLActor reads xmlFiles and then sends a message to HTTPActor to process. XMLActor will finish way sooner than HttpActor.

My main class calls join on both actors. I was expecting that the main thread would only terminate after both actors were done. But, what is actually happening is that as soon as all messages are processed by XMLActor, the system terminates and a lot of messages are not processed by HttpActor.

I could use some latch or even an AtomicInteger to wait for all messages to be consumed, but I was wondering if there's a more elegant way for it.

0 投票
1 回答
1031 浏览

groovy - 适当的 GPars 导入

仅使用以下导入是否合适?

这样我就可以做到:

代替:

这样做我就不必import static groovyx.gpars.actor.Actors.actor单独提及每个导入,就像在这个Hello World Example中一样。

0 投票
1 回答
10689 浏览

groovy - GPars:返回 eachParallel{}

我想对每个示例字符串做很多事情,并在这里返回一些其他类型的对象整数,然后返回一些更大的类对象。

在这个例子中,我正在尝试一些简单的事情,但我得到了一个完全错误的结果。至少对于我希望得到的东西。xD

我希望得到:[6, 5, 6, 5] 但相反,我得到:[butter, bread, dragon, table]

如果答案可以有一个简短的解释,那就太好了。非常感谢!

0 投票
1 回答
933 浏览

groovy - 如何使用 gpars 和 map reduce 折叠成多级地图

我有一组看起来像这样的地图:

我试图得到一个看起来像这样的结果,它对唯一 k​​ey1 和 key2 值的值进行分组和总结,并产生层次结构。

有很多映射例程只有一个键的示例,但是当使用多个键时,折叠这些例程的最佳方法是什么?

我想到的一个解决方案是使用 groupby 来获取按第一个键分组的列表。然后必须在每个元素的子列表上运行 combine 或 reduce 的问题:

在这一点上,我想减少分组地图的 .value() ,我在链中实际上无法做到这一点

我还尝试使用 combine,它的工作原理有点像这里的示例。然而,看起来如果 combine 得到一张地图,它想进一步组合它。

然后可以选择只在地图上进行归约,但是归约例程随后变成了一个非常复杂的组合嵌套地图的野兽。所以我想知道是否有更简单的东西,或者我应该运行一个 reduce 例程来组合复杂的映射。