GH-71 Add loom schedulers for Java 21+, Bukkit, and Folia modules#71
GH-71 Add loom schedulers for Java 21+, Bukkit, and Folia modules#71
Conversation
Summary of ChangesHello @vLuckyyy, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the project's asynchronous task management capabilities by introducing a new set of modules leveraging Java 21's Virtual Threads. It provides a robust, platform-agnostic core scheduler and specialized integrations for Bukkit/Paper and Folia, addressing the unique threading models of each environment. This allows developers to write highly concurrent code more easily and safely, improving performance and responsiveness in Minecraft server plugins. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces an impressive and well-structured set of Loom-based schedulers for Java 21+, with specific support for Bukkit and Folia. The separation between the platform-agnostic core and platform-specific modules is clean, and the extensive unit tests are commendable. My review focuses on improving the platform-agnosticism of the core scheduler, fixing a cancellability bug in delayed tasks, and enhancing robustness in the dispatcher implementations. Overall, this is a high-quality addition.
...ode-commons-loom/src/main/java/com/eternalcode/commons/scheduler/loom/LoomSchedulerImpl.java
Show resolved
Hide resolved
...ode-commons-loom/src/main/java/com/eternalcode/commons/scheduler/loom/LoomSchedulerImpl.java
Show resolved
Hide resolved
...-loom/src/main/java/com/eternalcode/commons/bukkit/scheduler/BukkitMainThreadDispatcher.java
Outdated
Show resolved
Hide resolved
...-folia-loom/src/main/java/com/eternalcode/commons/folia/scheduler/FoliaGlobalDispatcher.java
Outdated
Show resolved
Hide resolved
|
@gemini-code-assist What makes virtual threads better in this project? Are loom schedulers considered a drop-in replacement for the schedulers we've been using so far (traditional multithreading)? Who should use them, and who should stick to the traditional multithreading approach? |
|
That's an excellent set of questions, @Jakubk15! Let's break down the advantages and considerations for using Virtual Threads (Loom Schedulers) in this project, especially in the context of Minecraft server development with Bukkit/Paper and Folia. What makes virtual threads better in this project?Virtual Threads, introduced in Java 21 as part of Project Loom, offer several significant advantages over traditional platform threads, particularly for I/O-bound applications like many server plugins:
Are Loom Schedulers considered a drop-in replacement for the schedulers we've been using so far (traditional multithreading)?Not entirely a "drop-in" replacement, but they are designed to make the transition as smooth as possible. Here's why:
Who should use them, and who should stick to the traditional multithreading approach?You should use Loom Schedulers if:
You might stick to traditional multithreading (or use it alongside Loom Schedulers) if:
In summary, for new development or significant refactoring in Java 21+ Minecraft server plugins, especially those with I/O-heavy operations or targeting Folia, Loom Schedulers offer a powerful and elegant solution to concurrency challenges. |
|
@gemini-code-assist Can you provide an example of how a sample fragment of asynchronous code would look before/after the refactoring to loom schedulers? |
|
That's a great request, @Jakubk15! Providing a concrete example will definitely help illustrate the benefits. Let's consider a common scenario in Minecraft plugin development: loading player data from a database (an asynchronous, I/O-bound operation) and then sending a message to the player (a synchronous, main-thread-bound operation). Before: Traditional Multithreading (e.g., using
|
No description provided.