基于 Vala 和 GObject 的并行库:Gpseq 提供如下特性:
-
Work-stealing and managed blocking task scheduling: Similar behavior to Go scheduler
-
Functional programming for data processing with parallel execution support: An equivalent to Java’s streams
-
Fork-join parallelism
-
Parallel sorting
-
64-bit atomic operations
-
Overflow safe arithmetic functions for signed integers
References
-
Valadoc.org (暂未注册)
-
(TODO) pgi-docs (Python API)
-
(TODO) gjs-docs (JavaScript API)
案例代码
using Gpseq;
void main () {
string[] array = {"dog", "cat", "pig", "boar", "bear"};
Seq.of_array<string>(array)
.parallel()
.filter(g => g.length == 3)
.map<string>(g => g.up())
.foreach(g => print("%s\n", g))
.wait();
}
// (possibly unordered) output:
// DOG
// CAT
// PIG