基于 Vala 和 GObject 的并行库:Gpseq

原创
2019/11/12 17:02
阅读数 289

基于 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

  • Futures and promises

  • 64-bit atomic operations

  • Overflow safe arithmetic functions for signed integers

References

案例代码

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

 

展开阅读全文
打赏
1
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
1
分享
返回顶部
顶部