Use anonymous thread local here
This commit is contained in:
parent
9ca98f10be
commit
da66fa389d
@ -4,8 +4,13 @@ import com.github.benmanes.caffeine.cache.Interner
|
||||
import kotlin.concurrent.getOrSet
|
||||
|
||||
class PathStack(private val interner: Interner<String> = Interner { it }) {
|
||||
private val _stack = ThreadLocal<ArrayDeque<String>>()
|
||||
private val stack: ArrayDeque<String> get() = _stack.getOrSet { ArrayDeque() }
|
||||
private val _stack = object : ThreadLocal<ArrayDeque<String>>() {
|
||||
override fun initialValue(): ArrayDeque<String> {
|
||||
return ArrayDeque()
|
||||
}
|
||||
}
|
||||
|
||||
private val stack: ArrayDeque<String> get() = _stack.get()
|
||||
|
||||
fun push(value: String) {
|
||||
stack.addLast(value)
|
||||
|
Loading…
Reference in New Issue
Block a user