Liking cljdoc? Tell your friends :D

jepsen.generator.context

Generators work with an immutable context that tells them what time it is, what processes are available, what process is executing which thread and vice versa, and so on. We need an efficient, high-performance data structure to track this information. This namespace provides that data structure, and functions to alter it.

Contexts are intended not only for managing generator-relevant state about active threads and so on; they also can store arbitrary contextual information for generators. For instance, generators may thread state between invocations or layers of the generator stack. To do this, contexts also behave like Clojure maps. They have a single special key, :time; all other keys are available for your use.

Generators work with an immutable *context* that tells them what time it is,
what processes are available, what process is executing which thread and vice
versa, and so on. We need an efficient, high-performance data structure to
track this information. This namespace provides that data structure, and
functions to alter it.

Contexts are intended not only for managing generator-relevant state about
active threads and so on; they also can store arbitrary contextual
information for generators. For instance, generators may thread state between
invocations or layers of the generator stack. To do this, contexts *also*
behave like Clojure maps. They have a single special key, :time; all other
keys are available for your use.
raw docstring

all-butclj

(all-but x)

One thing we do often, and which is expensive, is stripping out the nemesis from the set of active threads using (complement #{:nemesis}). This type encapsulates that notion of "all but x", and allows us to specialize some expensive functions for speed.

One thing we do often, and which is expensive, is stripping out the nemesis
from the set of active threads using (complement #{:nemesis}). This type
encapsulates that notion of "all but x", and allows us to specialize some
expensive functions for speed.
raw docstring

all-processesclj

(all-processes ctx)

Given a context, returns a Bifurcan ISet of all processes currently belonging to some thread.

Given a context, returns a Bifurcan ISet of all processes
currently belonging to some thread.
raw docstring

all-thread-countclj

(all-thread-count ctx)

How many threads are in the given context, total?

How many threads are in the given context, total?
raw docstring

all-threadsclj

(all-threads ctx)

Given a context, returns a Bifurcan ISet of all threads in it.

Given a context, returns a Bifurcan ISet of all threads in it.
raw docstring

busy-threadclj

(busy-thread this time thread)

Returns context with the given time, and the given thread no longer free.

Returns context with the given time, and the given thread no
longer free.
raw docstring

contextclj

(context test)

Constructs a fresh Context for a test. Its initial time is 0. Its threads are the integers from 0 to (:concurrency test), plus a :nemesis). Every thread is free. Each initially runs itself as a process.

Constructs a fresh Context for a test. Its initial time is 0. Its threads
are the integers from 0 to (:concurrency test), plus a :nemesis). Every
thread is free. Each initially runs itself as a process.
raw docstring

free-processesclj

(free-processes ctx)

Given a context, returns a collection of processes which are not actively processing an invocation.

Given a context, returns a collection of processes which are
not actively processing an invocation.
raw docstring

free-threadclj

(free-thread this time thread)

Returns context with the given time, and the given thread free.

Returns context with the given time, and the given thread
free.
raw docstring

free-thread-countclj

(free-thread-count ctx)

How many threads are free in the given context?

How many threads are free in the given context?
raw docstring

free-threadsclj

(free-threads ctx)

Given a context, returns a Bifurcan ISet of threads which are not actively processing an invocation.

Given a context, returns a Bifurcan ISet of threads which are
not actively processing an invocation.
raw docstring

intersect-bitsetsclj

(intersect-bitsets a b)

Intersects one bitset with another, immutably.

Intersects one bitset with another, immutably.
raw docstring

make-thread-filterclj

(make-thread-filter pred)
(make-thread-filter pred ctx)

We often want to restrict a context to a specific subset of threads matching some predicate. We want to do this a lot. To make this fast, we can pre-compute a function which does this restriction more efficiently than doing it at runtime.

Call this with a context and a predicate, and it'll construct a function which restricts any version of that context (e.g. one with the same threads, but maybe a different time or busy state) to just threads matching the given predicate.

Don't have a context handy? Pass this just a predicate, and it'll construct a filter which lazily compiles itself on first invocation, and is fast thereafter.

We often want to restrict a context to a specific subset of threads matching
some predicate. We want to do this a *lot*. To make this fast, we can
pre-compute a function which does this restriction more efficiently than
doing it at runtime.

Call this with a context and a predicate, and it'll construct a function
which restricts any version of that context (e.g. one with the same threads,
but maybe a different time or busy state) to just threads matching the given
predicate.

Don't have a context handy? Pass this just a predicate, and it'll construct a
filter which lazily compiles itself on first invocation, and is fast
thereafter.
raw docstring

process->threadclj

(process->thread ctx process)

Given a process, looks up which thread is executing it.

Given a process, looks up which thread is executing it.
raw docstring

some-free-processclj

(some-free-process ctx)

Given a context, returns a random free process, or nil if all are busy.

Given a context, returns a random free process, or nil if
all are busy.
raw docstring

thread->processclj

(thread->process ctx thread)

Given a thread, looks up which process it's executing.

Given a thread, looks up which process it's executing.
raw docstring

thread-free?clj

(thread-free? ctx thread)

Is the given thread free?

Is the given thread free?
raw docstring

with-next-processclj

(with-next-process ctx thread)

Replaces a thread's process with a new one.

Replaces a thread's process with a new one.
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close