diff --git a/common/src/main/java/net/daporkchop/lib/common/misc/threadfactory/AbstractThreadFactory.java b/common/src/main/java/net/daporkchop/lib/common/misc/threadfactory/AbstractThreadFactory.java index daff17497..6f45ff010 100644 --- a/common/src/main/java/net/daporkchop/lib/common/misc/threadfactory/AbstractThreadFactory.java +++ b/common/src/main/java/net/daporkchop/lib/common/misc/threadfactory/AbstractThreadFactory.java @@ -1,7 +1,7 @@ /* * Adapted from The MIT License (MIT) * - * Copyright (c) 2018-2020 DaPorkchop_ + * Copyright (c) 2018-2021 DaPorkchop_ * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, @@ -21,6 +21,7 @@ package net.daporkchop.lib.common.misc.threadfactory; import lombok.Getter; +import lombok.NonNull; import lombok.RequiredArgsConstructor; import lombok.experimental.Accessors; @@ -35,15 +36,16 @@ @Getter @Accessors(fluent = true) public abstract class AbstractThreadFactory implements ThreadFactory { + protected final ThreadFactory delegate; protected final ClassLoader contextClassLoader; protected final Thread.UncaughtExceptionHandler uncaughtExceptionHandler; protected final int priority; protected final boolean daemon; @Override - public Thread newThread(Runnable task) { + public Thread newThread(@NonNull Runnable task) { Runnable wrappedTask = this.wrapTask(task); - Thread thread = PThreadFactories.DEFAULT_THREAD_FACTORY.newThread(wrappedTask); + Thread thread = this.delegate.newThread(wrappedTask); String name = this.getName(task, wrappedTask, thread); if (name != null) { @@ -62,9 +64,9 @@ public Thread newThread(Runnable task) { return thread; } - protected Runnable wrapTask(Runnable task) { + protected Runnable wrapTask(@NonNull Runnable task) { return task; } - protected abstract String getName(Runnable task, Runnable wrappedTask, Thread thread); + protected abstract String getName(@NonNull Runnable task, @NonNull Runnable wrappedTask, @NonNull Thread thread); } diff --git a/common/src/main/java/net/daporkchop/lib/common/misc/threadfactory/CollapsingIncrementingNamedThreadFactory.java b/common/src/main/java/net/daporkchop/lib/common/misc/threadfactory/CollapsingIncrementingNamedThreadFactory.java index 467813eb8..0c0425662 100644 --- a/common/src/main/java/net/daporkchop/lib/common/misc/threadfactory/CollapsingIncrementingNamedThreadFactory.java +++ b/common/src/main/java/net/daporkchop/lib/common/misc/threadfactory/CollapsingIncrementingNamedThreadFactory.java @@ -1,7 +1,7 @@ /* * Adapted from The MIT License (MIT) * - * Copyright (c) 2018-2020 DaPorkchop_ + * Copyright (c) 2018-2021 DaPorkchop_ * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, @@ -36,28 +36,29 @@ * @author DaPorkchop_ */ @Accessors(fluent = true) -public final class CollapsingIncrementingNamedThreadFactory extends AbstractThreadFactory { +public class CollapsingIncrementingNamedThreadFactory extends AbstractThreadFactory { @Getter protected final String format; protected final BitSet usedIds = new BitSet(); - public CollapsingIncrementingNamedThreadFactory(@NonNull String format, ClassLoader contextClassLoader, Thread.UncaughtExceptionHandler uncaughtExceptionHandler, int priority, boolean daemon) { - super(contextClassLoader, uncaughtExceptionHandler, priority, daemon); + public CollapsingIncrementingNamedThreadFactory(@NonNull String format, ThreadFactory delegate, ClassLoader contextClassLoader, Thread.UncaughtExceptionHandler uncaughtExceptionHandler, int priority, boolean daemon) { + super(delegate, contextClassLoader, uncaughtExceptionHandler, priority, daemon); this.format = format; } @Override - protected Runnable wrapTask(Runnable task) { + protected Runnable wrapTask(@NonNull Runnable task) { return new TaskWrapper(task); } @Override - protected String getName(Runnable task, Runnable wrappedTask, Thread thread) { + protected String getName(@NonNull Runnable task, @NonNull Runnable wrappedTask, @NonNull Thread thread) { return String.format(this.format, ((TaskWrapper) wrappedTask).id); } private final class TaskWrapper implements Runnable { + @NonNull protected final Runnable delegate; protected final int id; diff --git a/common/src/main/java/net/daporkchop/lib/common/misc/threadfactory/FixedNamedThreadFactory.java b/common/src/main/java/net/daporkchop/lib/common/misc/threadfactory/FixedNamedThreadFactory.java index 2b228d8d6..7772b8293 100644 --- a/common/src/main/java/net/daporkchop/lib/common/misc/threadfactory/FixedNamedThreadFactory.java +++ b/common/src/main/java/net/daporkchop/lib/common/misc/threadfactory/FixedNamedThreadFactory.java @@ -1,7 +1,7 @@ /* * Adapted from The MIT License (MIT) * - * Copyright (c) 2018-2020 DaPorkchop_ + * Copyright (c) 2018-2021 DaPorkchop_ * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, @@ -33,17 +33,17 @@ */ @Getter @Accessors(fluent = true) -public final class FixedNamedThreadFactory extends AbstractThreadFactory { +public class FixedNamedThreadFactory extends AbstractThreadFactory { protected final String name; - public FixedNamedThreadFactory(@NonNull String name, ClassLoader contextClassLoader, Thread.UncaughtExceptionHandler uncaughtExceptionHandler, int priority, boolean daemon) { - super(contextClassLoader, uncaughtExceptionHandler, priority, daemon); + public FixedNamedThreadFactory(@NonNull String name, ThreadFactory delegate, ClassLoader contextClassLoader, Thread.UncaughtExceptionHandler uncaughtExceptionHandler, int priority, boolean daemon) { + super(delegate, contextClassLoader, uncaughtExceptionHandler, priority, daemon); this.name = name; } @Override - protected String getName(Runnable task, Runnable wrappedTask, Thread thread) { + protected String getName(@NonNull Runnable task, @NonNull Runnable wrappedTask, @NonNull Thread thread) { return this.name; } } diff --git a/common/src/main/java/net/daporkchop/lib/common/misc/threadfactory/IncrementingNamedThreadFactory.java b/common/src/main/java/net/daporkchop/lib/common/misc/threadfactory/IncrementingNamedThreadFactory.java index 434ae51f6..5bad3a0c1 100644 --- a/common/src/main/java/net/daporkchop/lib/common/misc/threadfactory/IncrementingNamedThreadFactory.java +++ b/common/src/main/java/net/daporkchop/lib/common/misc/threadfactory/IncrementingNamedThreadFactory.java @@ -1,7 +1,7 @@ /* * Adapted from The MIT License (MIT) * - * Copyright (c) 2018-2020 DaPorkchop_ + * Copyright (c) 2018-2021 DaPorkchop_ * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, @@ -33,19 +33,19 @@ * @author DaPorkchop_ */ @Accessors(fluent = true) -public final class IncrementingNamedThreadFactory extends AbstractThreadFactory { +public class IncrementingNamedThreadFactory extends AbstractThreadFactory { @Getter protected final String format; protected final AtomicInteger counter = new AtomicInteger(); - public IncrementingNamedThreadFactory(@NonNull String format, ClassLoader contextClassLoader, Thread.UncaughtExceptionHandler uncaughtExceptionHandler, int priority, boolean daemon) { - super(contextClassLoader, uncaughtExceptionHandler, priority, daemon); + public IncrementingNamedThreadFactory(@NonNull String format, ThreadFactory delegate, ClassLoader contextClassLoader, Thread.UncaughtExceptionHandler uncaughtExceptionHandler, int priority, boolean daemon) { + super(delegate, contextClassLoader, uncaughtExceptionHandler, priority, daemon); this.format = format; } @Override - protected String getName(Runnable task, Runnable wrappedTask, Thread thread) { + protected String getName(@NonNull Runnable task, @NonNull Runnable wrappedTask, @NonNull Thread thread) { return String.format(this.format, this.counter.getAndIncrement()); } } diff --git a/common/src/main/java/net/daporkchop/lib/common/misc/threadfactory/ThreadFactoryBuilder.java b/common/src/main/java/net/daporkchop/lib/common/misc/threadfactory/ThreadFactoryBuilder.java index 7d7dcdc27..85260aad8 100644 --- a/common/src/main/java/net/daporkchop/lib/common/misc/threadfactory/ThreadFactoryBuilder.java +++ b/common/src/main/java/net/daporkchop/lib/common/misc/threadfactory/ThreadFactoryBuilder.java @@ -1,7 +1,7 @@ /* * Adapted from The MIT License (MIT) * - * Copyright (c) 2018-2020 DaPorkchop_ + * Copyright (c) 2018-2021 DaPorkchop_ * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, @@ -21,6 +21,7 @@ package net.daporkchop.lib.common.misc.threadfactory; import lombok.NoArgsConstructor; +import lombok.NonNull; import lombok.Setter; import lombok.experimental.Accessors; @@ -34,12 +35,14 @@ * @author DaPorkchop_ * @see PThreadFactories#builder() */ -@NoArgsConstructor(onConstructor_ = {@Deprecated}) +@NoArgsConstructor(onConstructor_ = { @Deprecated }) @Setter @Accessors(fluent = true, chain = true) public class ThreadFactoryBuilder { protected String name; + @NonNull + protected ThreadFactory delegate = PThreadFactories.DEFAULT_THREAD_FACTORY; protected ClassLoader contextClassLoader; protected Thread.UncaughtExceptionHandler uncaughtExceptionHandler; protected int priority = Thread.NORM_PRIORITY; @@ -105,19 +108,19 @@ public ThreadFactory build() { if (!this.formatId) { if (this.name == null) { if (this.contextClassLoader == null && this.uncaughtExceptionHandler == null && this.priority == Thread.NORM_PRIORITY && !this.daemon) { - return PThreadFactories.DEFAULT_THREAD_FACTORY; + return this.delegate; } else { - return new UnnamedThreadFactory(this.contextClassLoader, this.uncaughtExceptionHandler, this.priority, this.daemon); + return new UnnamedThreadFactory(this.delegate, this.contextClassLoader, this.uncaughtExceptionHandler, this.priority, this.daemon); } } else { - return new FixedNamedThreadFactory(this.name, this.contextClassLoader, this.uncaughtExceptionHandler, this.priority, this.daemon); + return new FixedNamedThreadFactory(this.name, this.delegate, this.contextClassLoader, this.uncaughtExceptionHandler, this.priority, this.daemon); } } else if (this.name == null) { throw new IllegalStateException("formatId is set, but no name is given!"); } else if (this.collapsingId) { - return new CollapsingIncrementingNamedThreadFactory(this.name, this.contextClassLoader, this.uncaughtExceptionHandler, this.priority, this.daemon); + return new CollapsingIncrementingNamedThreadFactory(this.name, this.delegate, this.contextClassLoader, this.uncaughtExceptionHandler, this.priority, this.daemon); } else { - return new IncrementingNamedThreadFactory(this.name, this.contextClassLoader, this.uncaughtExceptionHandler, this.priority, this.daemon); + return new IncrementingNamedThreadFactory(this.name, this.delegate, this.contextClassLoader, this.uncaughtExceptionHandler, this.priority, this.daemon); } } } diff --git a/common/src/main/java/net/daporkchop/lib/common/misc/threadfactory/UnnamedThreadFactory.java b/common/src/main/java/net/daporkchop/lib/common/misc/threadfactory/UnnamedThreadFactory.java index 470cdce4e..823da90ba 100644 --- a/common/src/main/java/net/daporkchop/lib/common/misc/threadfactory/UnnamedThreadFactory.java +++ b/common/src/main/java/net/daporkchop/lib/common/misc/threadfactory/UnnamedThreadFactory.java @@ -1,7 +1,7 @@ /* * Adapted from The MIT License (MIT) * - * Copyright (c) 2018-2020 DaPorkchop_ + * Copyright (c) 2018-2021 DaPorkchop_ * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, @@ -20,6 +20,8 @@ package net.daporkchop.lib.common.misc.threadfactory; +import lombok.NonNull; + import java.util.concurrent.ThreadFactory; /** @@ -27,13 +29,13 @@ * * @author DaPorkchop_ */ -public final class UnnamedThreadFactory extends AbstractThreadFactory { - public UnnamedThreadFactory(ClassLoader contextClassLoader, Thread.UncaughtExceptionHandler uncaughtExceptionHandler, int priority, boolean daemon) { - super(contextClassLoader, uncaughtExceptionHandler, priority, daemon); +public class UnnamedThreadFactory extends AbstractThreadFactory { + public UnnamedThreadFactory(ThreadFactory delegate, ClassLoader contextClassLoader, Thread.UncaughtExceptionHandler uncaughtExceptionHandler, int priority, boolean daemon) { + super(delegate, contextClassLoader, uncaughtExceptionHandler, priority, daemon); } @Override - protected String getName(Runnable task, Runnable wrappedTask, Thread thread) { + protected String getName(@NonNull Runnable task, @NonNull Runnable wrappedTask, @NonNull Thread thread) { return null; } } diff --git a/common/src/main/java/net/daporkchop/lib/common/misc/threadlocal/JavaTL.java b/common/src/main/java/net/daporkchop/lib/common/misc/threadlocal/JavaTL.java index 0bd1799d5..18a5b88b9 100644 --- a/common/src/main/java/net/daporkchop/lib/common/misc/threadlocal/JavaTL.java +++ b/common/src/main/java/net/daporkchop/lib/common/misc/threadlocal/JavaTL.java @@ -1,7 +1,7 @@ /* * Adapted from The MIT License (MIT) * - * Copyright (c) 2018-2020 DaPorkchop_ + * Copyright (c) 2018-2021 DaPorkchop_ * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, @@ -20,7 +20,10 @@ package net.daporkchop.lib.common.misc.threadlocal; +import lombok.Getter; +import lombok.NonNull; import lombok.RequiredArgsConstructor; +import lombok.experimental.Accessors; import java.util.function.Supplier; @@ -29,12 +32,32 @@ * * @author DaPorkchop_ */ -@RequiredArgsConstructor -final class JavaTL extends ThreadLocal implements TL { - protected final Supplier initialSupplier; +public class JavaTL extends ThreadLocal implements TL { + /** + * Extension of {@link JavaTL} with a fixed default initialization value. + * + * @author DaPorkchop_ + */ + @RequiredArgsConstructor + @Getter + @Accessors(fluent = true) + public static class WithConstant extends JavaTL { + protected final T initialValue; + } + + /** + * Extension of {@link JavaTL} which computes the default initialization value on-demand. + * + * @author DaPorkchop_ + */ + @RequiredArgsConstructor + public static class WithInitializer extends JavaTL { + @NonNull + protected final Supplier initialSupplier; - @Override - protected T initialValue() { - return this.initialSupplier != null ? this.initialSupplier.get() : null; + @Override + protected T initialValue() { + return this.initialSupplier.get(); + } } } diff --git a/common/src/main/java/net/daporkchop/lib/common/misc/threadlocal/FastTL.java b/common/src/main/java/net/daporkchop/lib/common/misc/threadlocal/NettyFastTL.java similarity index 62% rename from common/src/main/java/net/daporkchop/lib/common/misc/threadlocal/FastTL.java rename to common/src/main/java/net/daporkchop/lib/common/misc/threadlocal/NettyFastTL.java index 3a61368d7..a60cb41e7 100644 --- a/common/src/main/java/net/daporkchop/lib/common/misc/threadlocal/FastTL.java +++ b/common/src/main/java/net/daporkchop/lib/common/misc/threadlocal/NettyFastTL.java @@ -1,7 +1,7 @@ /* * Adapted from The MIT License (MIT) * - * Copyright (c) 2018-2020 DaPorkchop_ + * Copyright (c) 2018-2021 DaPorkchop_ * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, @@ -21,7 +21,10 @@ package net.daporkchop.lib.common.misc.threadlocal; import io.netty.util.concurrent.FastThreadLocal; +import lombok.Getter; +import lombok.NonNull; import lombok.RequiredArgsConstructor; +import lombok.experimental.Accessors; import java.util.function.Supplier; @@ -31,11 +34,32 @@ * @author DaPorkchop_ */ @RequiredArgsConstructor -final class FastTL extends FastThreadLocal implements TL { - protected final Supplier initialSupplier; +public class NettyFastTL extends FastThreadLocal implements TL { + /** + * Extension of {@link NettyFastTL} with a fixed default initialization value. + * + * @author DaPorkchop_ + */ + @RequiredArgsConstructor + @Getter + @Accessors(fluent = true) + public static class WithConstant extends NettyFastTL { + protected final T initialValue; + } + + /** + * Extension of {@link NettyFastTL} which computes the default initialization value on-demand. + * + * @author DaPorkchop_ + */ + @RequiredArgsConstructor + public static class WithInitializer extends NettyFastTL { + @NonNull + protected final Supplier initialSupplier; - @Override - protected T initialValue() { - return this.initialSupplier != null ? this.initialSupplier.get() : null; + @Override + protected T initialValue() { + return this.initialSupplier.get(); + } } } diff --git a/common/src/main/java/net/daporkchop/lib/common/misc/threadlocal/TL.java b/common/src/main/java/net/daporkchop/lib/common/misc/threadlocal/TL.java index 528cf2abb..da0fe548e 100644 --- a/common/src/main/java/net/daporkchop/lib/common/misc/threadlocal/TL.java +++ b/common/src/main/java/net/daporkchop/lib/common/misc/threadlocal/TL.java @@ -1,7 +1,7 @@ /* * Adapted from The MIT License (MIT) * - * Copyright (c) 2018-2020 DaPorkchop_ + * Copyright (c) 2018-2021 DaPorkchop_ * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, @@ -23,9 +23,12 @@ import io.netty.util.concurrent.FastThreadLocal; import lombok.NonNull; import net.daporkchop.lib.common.ref.Ref; +import net.daporkchop.lib.common.util.PorkUtil; import java.util.function.Supplier; +import static net.daporkchop.lib.common.util.PorkUtil.*; + /** * An abstracted form of a {@link ThreadLocal}, allowing transparent selection of alternative implementations (such as {@link FastThreadLocal}). * @@ -39,13 +42,22 @@ public interface TL extends Ref { * @return the new thread-local variable */ static TL create() { - try { - Class.forName("io.netty.util.concurrent.FastThreadLocal"); //make sure class exists + return NETTY_PRESENT + ? new NettyFastTL<>() + : new JavaTL<>(); + } - return new FastTL<>(null); - } catch (ClassNotFoundException e) { - return new JavaTL<>(null); - } + /** + * Creates a new thread-local variable which will be initially set to the given value, automatically selecting the best implementation to use. + * + * @param initialValue the initial value + * @param the value type + * @return the new thread-local variable + */ + static TL initializedTo(@NonNull T initialValue) { + return NETTY_PRESENT + ? new NettyFastTL.WithConstant<>(initialValue) + : new JavaTL.WithConstant<>(initialValue); } /** @@ -56,14 +68,10 @@ static TL create() { * @param the value type * @return the new thread-local variable */ - static TL withInitial(@NonNull Supplier initialSupplier) { - try { - Class.forName("io.netty.util.concurrent.FastThreadLocal"); //make sure class exists - - return new FastTL<>(initialSupplier); - } catch (ClassNotFoundException e) { - return new JavaTL<>(initialSupplier); - } + static TL initializedWith(@NonNull Supplier initialSupplier) { + return NETTY_PRESENT + ? new NettyFastTL.WithInitializer<>(initialSupplier) + : new JavaTL.WithInitializer<>(initialSupplier); } /** diff --git a/common/src/main/java/net/daporkchop/lib/common/ref/ThreadRef.java b/common/src/main/java/net/daporkchop/lib/common/ref/ThreadRef.java index d6c48caae..a5b7f09b4 100644 --- a/common/src/main/java/net/daporkchop/lib/common/ref/ThreadRef.java +++ b/common/src/main/java/net/daporkchop/lib/common/ref/ThreadRef.java @@ -1,7 +1,7 @@ /* * Adapted from The MIT License (MIT) * - * Copyright (c) 2018-2020 DaPorkchop_ + * Copyright (c) 2018-2021 DaPorkchop_ * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, @@ -34,11 +34,11 @@ */ public interface ThreadRef extends Ref { /** - * @deprecated see {@link TL#withInitial(Supplier)} + * @deprecated see {@link TL#initializedWith(Supplier)} */ @Deprecated static Ref late(@NonNull Supplier supplier) { - return TL.withInitial(supplier); + return TL.initializedWith(supplier); } /** diff --git a/common/src/main/java/net/daporkchop/lib/common/util/PorkUtil.java b/common/src/main/java/net/daporkchop/lib/common/util/PorkUtil.java index 20f2dd655..a3212494f 100644 --- a/common/src/main/java/net/daporkchop/lib/common/util/PorkUtil.java +++ b/common/src/main/java/net/daporkchop/lib/common/util/PorkUtil.java @@ -1,7 +1,7 @@ /* * Adapted from The MIT License (MIT) * - * Copyright (c) 2018-2020 DaPorkchop_ + * Copyright (c) 2018-2021 DaPorkchop_ * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, @@ -73,6 +73,8 @@ public class PorkUtil { public final Object[] EMPTY_OBJECT_ARRAY = new Object[0]; + public final boolean NETTY_PRESENT = classExistsWithName("io.netty.util.concurrent.FastThreadLocal"); + /** * An alternative to {@link CharSequence#subSequence(int, int)} that can be faster for certain {@link CharSequence} implementations. * diff --git a/compression/zstd/src/main/java/net/daporkchop/lib/compression/zstd/natives/NativeZstdDeflateStream.java b/compression/zstd/src/main/java/net/daporkchop/lib/compression/zstd/natives/NativeZstdDeflateStream.java index 4d05142c9..3d1e252b5 100644 --- a/compression/zstd/src/main/java/net/daporkchop/lib/compression/zstd/natives/NativeZstdDeflateStream.java +++ b/compression/zstd/src/main/java/net/daporkchop/lib/compression/zstd/natives/NativeZstdDeflateStream.java @@ -1,7 +1,7 @@ /* * Adapted from The MIT License (MIT) * - * Copyright (c) 2018-2020 DaPorkchop_ + * Copyright (c) 2018-2021 DaPorkchop_ * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, @@ -181,11 +181,6 @@ protected int drain() throws IOException { } } - @Override - protected Object mutex() { - return this.deflater; - } - @Override protected void ensureOpen() throws IOException { super.ensureOpen(); diff --git a/crypto/src/main/java/net/daporkchop/lib/crypto/cipher/block/IVUpdater.java b/crypto/src/main/java/net/daporkchop/lib/crypto/cipher/block/IVUpdater.java index 01188877b..0f64da707 100644 --- a/crypto/src/main/java/net/daporkchop/lib/crypto/cipher/block/IVUpdater.java +++ b/crypto/src/main/java/net/daporkchop/lib/crypto/cipher/block/IVUpdater.java @@ -1,7 +1,7 @@ /* * Adapted from The MIT License (MIT) * - * Copyright (c) 2018-2020 DaPorkchop_ + * Copyright (c) 2018-2021 DaPorkchop_ * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, @@ -21,6 +21,7 @@ package net.daporkchop.lib.crypto.cipher.block; import lombok.NonNull; +import net.daporkchop.lib.common.ref.Ref; import net.daporkchop.lib.common.ref.ThreadRef; import net.daporkchop.lib.hash.util.Digest; @@ -36,7 +37,7 @@ public interface IVUpdater extends Consumer { IVUpdater SHA3_256 = ofHash(Digest.SHA3_256); static IVUpdater ofHash(@NonNull Digest digest) { - ThreadRef cache = ThreadRef.soft(() -> new byte[digest.getHashSize()]); + Ref cache = ThreadRef.soft(() -> new byte[digest.getHashSize()]); return iv -> { byte[] buf = cache.get(); for (int i = 0; i < iv.length; i += buf.length) {