From 74ed0ea729bdf19a4ba0329524b31669fdfea2a4 Mon Sep 17 00:00:00 2001 From: crafter23456 <64259198+crafter23456@users.noreply.github.com> Date: Sun, 3 Apr 2022 01:54:21 +0200 Subject: [PATCH] Update readme (#395) * update readme * update guava * Update Futures.java * Update MoreExecutors.java * Update NachoSpigot-API/src/main/java/com/google/common/util/concurrent/MoreExecutors.java Co-authored-by: Elier <71361901+Elierrr@users.noreply.github.com> --- NachoSpigot-API/pom.xml | 2 +- .../common/util/concurrent/Futures.java | 6 +++- .../common/util/concurrent/MoreExecutors.java | 34 ++++++++++++------- README.md | 4 +-- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/NachoSpigot-API/pom.xml b/NachoSpigot-API/pom.xml index 8a365a691..d8fd7b27a 100644 --- a/NachoSpigot-API/pom.xml +++ b/NachoSpigot-API/pom.xml @@ -48,7 +48,7 @@ com.google.guava guava - 31.0.1-jre + 31.1-jre compile diff --git a/NachoSpigot-API/src/main/java/com/google/common/util/concurrent/Futures.java b/NachoSpigot-API/src/main/java/com/google/common/util/concurrent/Futures.java index 03dc028d9..7c147f647 100644 --- a/NachoSpigot-API/src/main/java/com/google/common/util/concurrent/Futures.java +++ b/NachoSpigot-API/src/main/java/com/google/common/util/concurrent/Futures.java @@ -172,7 +172,11 @@ private Futures() {} * @since 14.0 */ public static ListenableFuture immediateCancelledFuture() { - return new ImmediateCancelledFuture(); + ListenableFuture instance = ImmediateCancelledFuture.INSTANCE; + if (instance != null) { + return (ListenableFuture) instance; + } + return new ImmediateCancelledFuture<>(); } /** diff --git a/NachoSpigot-API/src/main/java/com/google/common/util/concurrent/MoreExecutors.java b/NachoSpigot-API/src/main/java/com/google/common/util/concurrent/MoreExecutors.java index 24b84d3c7..20295c66b 100644 --- a/NachoSpigot-API/src/main/java/com/google/common/util/concurrent/MoreExecutors.java +++ b/NachoSpigot-API/src/main/java/com/google/common/util/concurrent/MoreExecutors.java @@ -440,14 +440,22 @@ public static ListeningExecutorService newDirectExecutorService() { * difficult to reproduce because they depend on timing. For example: * *
    - *
  • A call like {@code future.transform(function, directExecutor())} may execute the function - * immediately in the thread that is calling {@code transform}. (This specific case happens - * if the future is already completed.) If {@code transform} call was made from a UI thread - * or other latency-sensitive thread, a heavyweight function can harm responsiveness. - *
  • If the task will be executed later, consider which thread will trigger the execution -- - * since that thread will execute the task inline. If the thread is a shared system thread - * like an RPC network thread, a heavyweight task can stall progress of the whole system or - * even deadlock it. + *
  • When a {@code ListenableFuture} listener is registered to run under {@code + * directExecutor}, the listener can execute in any of three possible threads: + *
      + *
    1. When a thread attaches a listener to a {@code ListenableFuture} that's already + * complete, the listener runs immediately in that thread. + *
    2. When a thread attaches a listener to a {@code ListenableFuture} that's + * incomplete and the {@code ListenableFuture} later completes normally, the + * listener runs in the the thread that completes the {@code ListenableFuture}. + *
    3. When a listener is attached to a {@code ListenableFuture} and the {@code + * ListenableFuture} gets cancelled, the listener runs immediately in the the thread + * that cancelled the {@code Future}. + *
    + * Given all these possibilities, it is frequently possible for listeners to execute in UI + * threads, RPC network threads, or other latency-sensitive threads. In those cases, slow + * listeners can harm responsiveness, slow the system as a whole, or worse. (See also the + * note about locking below.) *
  • If many tasks will be triggered by the same event, one heavyweight task may delay other * tasks -- even tasks that are not themselves {@code directExecutor} tasks. *
  • If many such tasks are chained together (such as with {@code @@ -463,9 +471,11 @@ public static ListeningExecutorService newDirectExecutorService() { * terminate whichever thread happens to trigger the execution. *
* - * Additionally, beware of executing tasks with {@code directExecutor} while holding a lock. Since - * the task you submit to the executor (or any other arbitrary work the executor does) may do slow - * work or acquire other locks, you risk deadlocks. + * A specific warning about locking: Code that executes user-supplied tasks, such as {@code + * ListenableFuture} listeners, should take care not to do so while holding a lock. Additionally, + * as a further line of defense, prefer not to perform any locking inside a task that will be run + * under {@code directExecutor}: Not only might the wait for a lock be long, but if the running + * thread was holding a lock, the listener may deadlock or break lock isolation. * *

This instance is equivalent to: * @@ -1169,4 +1179,4 @@ public static ListeningExecutorService sameThreadExecutor() { return newDirectExecutorService(); } // Nacho end -} \ No newline at end of file +} diff --git a/README.md b/README.md index 256c1355d..fbb873b63 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# NachoSpigot [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/CobbleSword/NachoSpigot/NachoSpigot%20Build)](https://nightly.link/CobbleSword/NachoSpigot/workflows/build-nachospigot/master/NachoSpigot-server.zip) +# NachoSpigot [![GitHub Workflow Status](https://github.com/CobbleSword/NachoSpigot/actions/workflows/build-nachospigot.yml/badge.svg)](https://nightly.link/CobbleSword/NachoSpigot/workflows/build-nachospigot/master/NachoSpigot-server.zip) NachoSpigot offers a number of enhancements to performance as well as bug fixes and being able to perform well with a large number of players. @@ -15,7 +15,7 @@ If this ever causes issues, we can disable this and hope none of this ever happe ## Current State Java 17 (LTS) is the recommended version to use, otherwise Java 11 is fine. Java 8 works, but is not recommended due to security issues. -**NachoSpigot supports Java 8 to Java 17!** +**NachoSpigot supports Java 8 to Java 18!** Nacho can be used in production environments with a good degree of stability.