Apache License 2.0

项目介绍

softwaremill/jox 是一个托管在 GitHub 上的开源项目,主要使用 Java 编写,采用 Apache License 2.0 许可证,目前获得 427 个 Star、17 次 Fork。

仓库全名
softwaremill/jox
开源许可证
Apache License 2.0
Star 数
427
Fork 数
17
未关闭 Issue
17

README 摘要

Jox Virtual-thread based safe concurrency & streaming for Java. Includes: Fast & scalable, completable channels, with Go-like selects (Java 21+) Programmer-friendly structured concurrency (Java 25 only) Finite & infinite streaming using flows, with reactive streams compatibility, (blocking) I/O integration and a high-level, “functional” API (Java 25 only) Flow integrations: Kafka, streaming JSON (NDJSON, JSON…

完整内容见 GitHub 原始 README 或本页 。

常见问题

jox 用什么语言开发?

主要使用 Java 编写,采用 Apache License 2.0 许可证,目前有 427 个 Star。

jox 可以免费商用吗?

仓库采用 Apache License 2.0 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 jox 的源码?

可以直接克隆仓库:git clone https://github.com/softwaremill/jox.git,默认分支为 main;安装与运行步骤见仓库 README。

jox 最近还在维护吗?

仓库最近一次更新为 6 天前,当前有 17 个未关闭 Issue;Star 数为 427,可作为社区活跃度的参考。

关于

Virtual-thread based safe concurrency & streaming

描述取自 GitHub 官方 API,中文内容由 GitRead 中文社区 编辑团队整理。

简要分析

热度分
480
价值分
262
活跃状态
活跃

语言占比

Go
Java
Kotlin

Release

README

Jox

Ideas, suggestions, problems, questions CI javadoc (channels) javadoc (flows)

Virtual-thread based safe concurrency & streaming for Java.

Includes:

  • Fast & scalable, completable channels, with Go-like selects (Java 21+)
  • Programmer-friendly structured concurrency (Java 25 only)
  • Finite & infinite streaming using flows, with reactive streams compatibility, (blocking) I/O integration and a high-level, “functional” API (Java 25 only)
  • Flow integrations: Kafka, streaming JSON (NDJSON, JSON arrays) (Java 25 only)

Find out more in the documentation available at jox.softwaremill.com.

A tour of Jox

Selectable channels:

var ch1 = Channel.<Integer>newBufferedDefaultChannel();
var ch2 = Channel.<Integer>newBufferedDefaultChannel();
var ch3 = Channel.<Integer>newBufferedDefaultChannel();

// send a value to two channels
ch2.send(29);
ch3.send(32);

var received = select(ch1.receiveClause(), ch2.receiveClause(), ch3.receiveClause());

A push-based, backpressured flow with time-based & parallel processing:

var nats =
  Flows.unfold(0, i -> Optional.of(Map.entry(i+1, i+1)));
 
Flows.range(1, 100, 1)
  .throttle(1, Duration.ofSeconds(1))
  .mapPar(4, i -> {
    Thread.sleep(5000);
    var j = i*3;
    return j+1;
  })
  .filter(i -> i % 2 == 0)
  .zip(nats)
  .runForeach(IO::println);

Structured concurrency scope:

var result = supervised(scope -> {
    var f1 = scope.fork(() -> {
        Thread.sleep(500);
        return 5;
    });
    var f2 = scope.fork(() -> {
        Thread.sleep(1000);
        return 6;
    });
    return f1.join() + f2.join();
});
IO.println("result = " + result);

Feedback

Is what we are looking for!

Let us know in the issues, or our community forum.

Project sponsor

We offer commercial development services. Contact us to learn more!

Building & working on Jox

Jox uses the spotless maven plugin to format code. The formatting is automatically applied during compilation. Formatting can be checked using mvn spotless:check and applied with mvn spotless:apply.

When using VS Code, format-on-save should be disabled (see the pom.xml). For IntelliJ, it might be necessary to install the spotless plugin to properly reformat the sources.

Channel concurrency tests using Fray

Apart from unit & stress tests, which live in the channels/src/test/java directory, Jox includes additional concurrency tests using the Fray library. The library runs a number of randomized, but deterministic tests using orchestrated code & JVM. That way, even though the tests are not exhaustive, so we are not able to prove that the code is 100% race & deadlock-free, we gain a new approach to verifying thread interleavings which would otherwise be hard to obtain.

The concurrency tests are only run when the integration-tests profile is enabled. That is, when in the channels-fray-tests module:

  • mvn test - Tests are skipped
  • mvn verify - Tests are skipped
  • mvn integration-test -Pintegration-tests - Tests run during the integration-test phase
  • mvn verify -Pintegration-tests - Tests run during the integration-test phase

The test runs can be parametrized using the CHANNEL_SIZE and JOX_SEGMENT_SIZE environment variables. By default, these have the values 16 and 32. Note that the segment size affects not only the tests, but all channels, so be careful to change it only for scoped test runs.

Copyright © 2023-2026 SoftwareMill https://softwaremill.com.

评论

暂无评论