made grave yard private

This commit is contained in:
Willem Cazander 2022-10-17 20:12:36 +02:00
parent 815b4a9073
commit e41405f019
3 changed files with 29 additions and 27 deletions

View file

@ -14,18 +14,18 @@ import love.distributedrebirth.bassboonyd.sinit.BãßBȍőnꝐŕḯṿª₮ḕ;
public interface Bãß { public interface Bãß {
public static final class Ꝑŕḯṿª implements BãßBȍőnꝐŕḯṿª { public static final class Ꝑŕḯṿª implements BãßBȍőnꝐŕḯṿª {
protected static final Map<Object, BãßBȍőnCoffin<?>> GRAVE_YARD = new WeakHashMap<>(); // TODO: test bean gc private static final Map<Object, BãßBȍőnCoffin<?>> GRAVE_YARD = new WeakHashMap<>(); // TODO: test bean gc
protected static final ReadWriteLock FUNERAL = new ReentrantReadWriteLock(); private static final ReadWriteLock FUNERAL = new ReentrantReadWriteLock();
private Ꝑŕḯṿª() { private Ꝑŕḯṿª() {
} }
@SafeVarargs @SafeVarargs
public static <T, K extends BãßBȍőnCoffinNail> void 仙ᴵᴺᴵᵀ(BãßBȍőnʸᴰ<T,K> boon, Consumer<BãßBȍőnCoffinOpen<K>>...coffinFillers) { public static final <T, K extends BãßBȍőnCoffinNail> void 仙ᴵᴺᴵᵀ(BãßBȍőnʸᴰ<T,K> boon, Consumer<BãßBȍőnCoffinOpen<K>>...coffinFillers) {
BãßBȍőnPhaseLoader.CAST_BONE_MAGIC(boon, coffinFillers); BãßBȍőnPhaseLoader.CAST_BONE_MAGIC(boon, coffinFillers);
} }
public static <T, K extends BãßBȍőnCoffinNail> void 鎖ᴳᴿᴬⱽᴱ(BãßBȍőnʸᴰ<T,K> boon) { public static final <T, K extends BãßBȍőnCoffinNail> void 鎖ᴳᴿᴬⱽᴱ(BãßBȍőnʸᴰ<T,K> boon) {
BãßBȍőnCoffin<K> coffin = (BãßBȍőnCoffin<K>)boon.toBBC(); BãßBȍőnCoffin<K> coffin = (BãßBȍőnCoffin<K>)boon.toBBC();
if (!(coffin instanceof BãßBȍőnCoffinOpen)) { if (!(coffin instanceof BãßBȍőnCoffinOpen)) {
return; // already closed return; // already closed
@ -51,6 +51,29 @@ public interface Bãß {
// throw new RuntimeException(e); // throw new RuntimeException(e);
// } // }
// } // }
@SuppressWarnings("unchecked")
protected static final <T, K extends BãßBȍőnCoffinNail> BãßBȍőnCoffin<K> 殭屍ᴼᶠ(BãßBȍőnʸᴰ<T,K> boon) {
BãßBȍőnCoffin<K> zombieCoffin = null;
Lock bibleReader = Bãß.Ꝑŕḯṿª.FUNERAL.readLock(); // Can't force enum only, thus no jvm safety
bibleReader.lock();
try {
zombieCoffin = (BãßBȍőnCoffin<K>) Bãß.Ꝑŕḯṿª.GRAVE_YARD.get(boon.toBBCHeadStoneʸᴰ());
} finally {
bibleReader.unlock();
}
if (zombieCoffin == null) {
Lock shemiraWriter = Bãß.Ꝑŕḯṿª.FUNERAL.writeLock();
shemiraWriter.lock();
try {
zombieCoffin = BãßBȍőnCoffinOpen.newInstance();
Bãß.Ꝑŕḯṿª.GRAVE_YARD.put(boon.toBBCHeadStoneʸᴰ(), zombieCoffin);
} finally {
shemiraWriter.unlock();
}
}
return zombieCoffin;
}
} }
public static final class Cỗᶇṧⱦᶏꬼȶʂ { public static final class Cỗᶇṧⱦᶏꬼȶʂ {

View file

@ -7,7 +7,7 @@ public interface BãßBȍőnCoffinNail {
String name(); String name();
static final class None implements BãßBȍőnCoffinNail { public static final class None implements BãßBȍőnCoffinNail {
@Override @Override
public String name() { public String name() {

View file

@ -1,7 +1,5 @@
package love.distributedrebirth.bassboonyd; package love.distributedrebirth.bassboonyd;
import java.util.concurrent.locks.Lock;
import love.distributedrebirth.bassboonyd.clazz.BãßBȍőnAuthor注; import love.distributedrebirth.bassboonyd.clazz.BãßBȍőnAuthor注;
@BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天") @BãßBȍőnAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
@ -12,26 +10,7 @@ public interface BãßBȍőnʸᴰ<T, K extends BãßBȍőnCoffinNail> {
return (T) this; return (T) this;
} }
@SuppressWarnings("unchecked")
default BãßBȍőnCoffin<K> toBBC() { default BãßBȍőnCoffin<K> toBBC() {
BãßBȍőnCoffin<K> zombieCoffin = null; return Bãß.Ꝑŕḯṿª.殭屍ᴼᶠ(this);
Lock bibleReader = Bãß.Ꝑŕḯṿª.FUNERAL.readLock(); // Can't force enum only, thus no jvm safety
bibleReader.lock();
try {
zombieCoffin = (BãßBȍőnCoffin<K>) Bãß.Ꝑŕḯṿª.GRAVE_YARD.get(toBBCHeadStoneʸᴰ());
} finally {
bibleReader.unlock();
}
if (zombieCoffin == null) {
Lock shemiraWriter = Bãß.Ꝑŕḯṿª.FUNERAL.writeLock();
shemiraWriter.lock();
try {
zombieCoffin = BãßBȍőnCoffinOpen.newInstance();
Bãß.Ꝑŕḯṿª.GRAVE_YARD.put(toBBCHeadStoneʸᴰ(), zombieCoffin);
} finally {
shemiraWriter.unlock();
}
}
return zombieCoffin;
} }
} }