EnsuredOnce

class EnsuredOnce<K : Any, T : Any>

The structures a store has made sure of (created, registered, format checked), by key: each is made sure of once, on its first use, and then costs the store nothing.

Concurrent first uses of one key wait for one ensure rather than each running its own, which would send its schema statements as many times at once. They wait on a ReentrantLock, not a monitor (computeIfAbsent): a virtual thread blocked on a monitor pins its carrier, and the ensure runs blocking driver calls. An ensure that fails keeps nothing; the next use runs it again.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

What was made sure of so far.

Functions

Link copied to clipboard
fun forget(key: K, value: T)

Forgets value, the structure of key that turned out to be gone, so that its next use makes sure of it again.

Link copied to clipboard
fun get(key: K, ensure: () -> T): T

The structure of key, made sure of by ensure when it is not yet, once however many ask at once.