mirror of
https://github.com/Minestom/Minestom.git
synced 2024-09-28 22:47:41 +02:00
Remove explicit fences
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
7a371fe616
commit
467decbb20
@ -3,7 +3,6 @@ package net.minestom.server.network.packet.server;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.invoke.VarHandle;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
@ -14,21 +13,18 @@ import java.util.function.Supplier;
|
||||
@ApiStatus.Internal
|
||||
public final class LazyPacket implements SendablePacket {
|
||||
private final Supplier<ServerPacket> packetSupplier;
|
||||
private ServerPacket packet;
|
||||
private volatile ServerPacket packet;
|
||||
|
||||
public LazyPacket(@NotNull Supplier<@NotNull ServerPacket> packetSupplier) {
|
||||
this.packetSupplier = packetSupplier;
|
||||
}
|
||||
|
||||
public @NotNull ServerPacket packet() {
|
||||
VarHandle.acquireFence();
|
||||
ServerPacket packet = this.packet;
|
||||
if (packet == null) {
|
||||
synchronized (this) {
|
||||
packet = this.packet;
|
||||
if (packet == null) {
|
||||
this.packet = packet = packetSupplier.get();
|
||||
}
|
||||
if (packet == null) this.packet = packet = packetSupplier.get();
|
||||
}
|
||||
}
|
||||
return packet;
|
||||
|
@ -9,7 +9,6 @@ import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
||||
import org.jglrxavpok.hephaistos.nbt.NBTCompoundLike;
|
||||
import org.jglrxavpok.hephaistos.nbt.mutable.MutableNBTCompound;
|
||||
|
||||
import java.lang.invoke.VarHandle;
|
||||
import java.util.Arrays;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
@ -153,7 +152,7 @@ final class TagHandlerImpl implements TagHandler {
|
||||
private static final class Entry<T> {
|
||||
final Tag<T> tag;
|
||||
final T value; // TagHandler type for path-able tags
|
||||
private NBT nbt;
|
||||
volatile NBT nbt;
|
||||
|
||||
Entry(Tag<T> tag, T value) {
|
||||
this.tag = tag;
|
||||
@ -161,12 +160,8 @@ final class TagHandlerImpl implements TagHandler {
|
||||
}
|
||||
|
||||
NBT updatedNbt() {
|
||||
VarHandle.acquireFence();
|
||||
NBT nbt = this.nbt;
|
||||
if (nbt == null) {
|
||||
this.nbt = nbt = tag.writeFunction.apply(value);
|
||||
VarHandle.releaseFence();
|
||||
}
|
||||
if (nbt == null) this.nbt = nbt = tag.writeFunction.apply(value);
|
||||
return nbt;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user