MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / PerThread

Class PerThread

src/main/java/field/utility/KotlinExtensions.kt:81–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79 */
80
81class PerThread<T>(val initial: () -> T) : ReadWriteProperty<Any, T> {
82
83 val t: ThreadLocal<T> = ThreadLocal.withInitial { initial() }
84
85 override fun getValue(thisRef: Any, property: KProperty<*>): T {
86 return t.get()
87 }
88
89 override fun setValue(thisRef: Any, property: KProperty<*>, value: T) {
90 t.set(value)
91 }
92
93}
94
95
96/**

Callers 1

AstaClass · 0.85

Calls 1

initialFunction · 0.85

Tested by

no test coverage detected