mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-05 02:10:24 +01:00
Event nodes need total order
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
a689691873
commit
131116013d
@ -7,7 +7,6 @@ import org.jetbrains.annotations.Contract;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.lang.invoke.VarHandle;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
@ -308,7 +307,7 @@ non-sealed class EventNodeImpl<T extends Event> implements EventNode<T> {
|
|||||||
final class Handle<E extends Event> implements ListenerHandle<E> {
|
final class Handle<E extends Event> implements ListenerHandle<E> {
|
||||||
private final Class<E> eventType;
|
private final Class<E> eventType;
|
||||||
private Consumer<E> listener = null;
|
private Consumer<E> listener = null;
|
||||||
private boolean updated;
|
private volatile boolean updated;
|
||||||
|
|
||||||
Handle(Class<E> eventType) {
|
Handle(Class<E> eventType) {
|
||||||
this.eventType = eventType;
|
this.eventType = eventType;
|
||||||
@ -332,11 +331,9 @@ non-sealed class EventNodeImpl<T extends Event> implements EventNode<T> {
|
|||||||
|
|
||||||
void invalidate() {
|
void invalidate() {
|
||||||
this.updated = false;
|
this.updated = false;
|
||||||
VarHandle.releaseFence();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable Consumer<E> updatedListener() {
|
@Nullable Consumer<E> updatedListener() {
|
||||||
VarHandle.acquireFence();
|
|
||||||
if (updated) return listener;
|
if (updated) return listener;
|
||||||
synchronized (GLOBAL_CHILD_LOCK) {
|
synchronized (GLOBAL_CHILD_LOCK) {
|
||||||
if (updated) return listener;
|
if (updated) return listener;
|
||||||
|
Loading…
Reference in New Issue
Block a user