fun withStore()

in dnq/src/main/kotlin/kotlinx/dnq/store/container/ThreadLocalStoreContainer.kt [28:40]


    fun <T> withStore(store: TransientEntityStore, body: () -> T): T {
        val oldStore = storeThreadLocal.get()
        storeThreadLocal.set(store)
        try {
            return body()
        } finally {
            if (oldStore != null) {
                storeThreadLocal.set(oldStore)
            } else {
                storeThreadLocal.remove()
            }
        }
    }