withPrompt
Atomically replaces prompt with the result of applying block to the current prompt while holding the internal write lock. Callers waiting for read or write access will be suspended until the transformation completes.
Concurrency warnings:
Must not be invoked from inside another withPrompt, writeSession, or readSession on the same context — the underlying lock is not reentrant and doing so will deadlock (see RWLock).
block should be a pure, fast transformation; it runs while holding the write lock and will block all concurrent readers and writers until it returns.
Parameters
block
transformation to produce the next Prompt.