Documentation
¶
Overview ¶
Package sync provides interfaces for managing externally synchronized APIs.
The methods allow queries to be performed on an API to allow the determination of where blocking operations between threads of execution happen. These methods allow us to reason about execution in a non-linear way.
Index ¶
- func MutateWithSubcommands(ctx context.Context, c *path.Capture, cmds []api.Cmd, ...) error
- func MutationCmdsFor(ctx context.Context, c *path.Capture, cmds []api.Cmd, id api.CmdID, ...) ([]api.Cmd, error)
- type Data
- type ExecutionRanges
- type SubcommandIndex
- type SynchronizationIndices
- type SynchronizedAPI
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MutateWithSubcommands ¶
func MutateWithSubcommands(ctx context.Context, c *path.Capture, cmds []api.Cmd, callback func(*api.State, SubcommandIndex, api.Cmd)) error
MutateWithSubcommands returns a list of commands that represent the correct mutations to have the state for all commands before and including the given index.
func MutationCmdsFor ¶
func MutationCmdsFor(ctx context.Context, c *path.Capture, cmds []api.Cmd, id api.CmdID, subindex []uint64) ([]api.Cmd, error)
MutationCmdsFor returns a list of command that represent the correct mutations to have the state for all commands before and including the given index.
Types ¶
type Data ¶
type Data struct {
CommandRanges map[api.CmdID]ExecutionRanges
}
Data contains a map of synchronization pairs. The api.CmdID is the command that will be blocked from completion, and what subcommands will be made available by future commands.
func (Data) SortedKeys ¶
func (s Data) SortedKeys() SynchronizationIndices
SortedKeys returns the keys of 's' in sorted order
type ExecutionRanges ¶
type ExecutionRanges struct {
LastIndex SubcommandIndex
Ranges map[api.CmdID]SubcommandIndex
}
ExecutionRanges contains the information about a blocked command. LastIndex is the final subcommand that exists within this command. Ranges defines which future command will unblock the command in question, and which subcommandis the last that will be run at that point.
func (ExecutionRanges) SortedKeys ¶
func (e ExecutionRanges) SortedKeys() SynchronizationIndices
SortedKeys returns the keys of 'e' in sorted order
type SubcommandIndex ¶
type SubcommandIndex []uint64
The index of a subcommand within a command
func (*SubcommandIndex) Decrement ¶
func (s *SubcommandIndex) Decrement()
Decrement returns the subcommand that preceded this subcommand. Decrement will decrement its way UP subcommand chains. Eg: {0, 1}.Decrement() == {0, 0}
{1, 0}.Decrement() == {0}
{0}.Decrement() == {}
func (SubcommandIndex) LEQ ¶
func (s SubcommandIndex) LEQ(s2 SubcommandIndex) bool
LEQ returns true if s comes before s2.
func (SubcommandIndex) LessThan ¶
func (s SubcommandIndex) LessThan(s2 SubcommandIndex) bool
LessThan returns true if s comes before s2.
type SynchronizationIndices ¶
An index defines the location of one side synchronization dependency.
func (SynchronizationIndices) Len ¶
func (s SynchronizationIndices) Len() int
Len returns the length of subcommand indices
func (SynchronizationIndices) Less ¶
func (s SynchronizationIndices) Less(i, j int) bool
Less returns true if s[i] < s[j]
func (SynchronizationIndices) Swap ¶
func (s SynchronizationIndices) Swap(i, j int)
Swap swaps the 2 subcommands in the given slice
type SynchronizedAPI ¶
type SynchronizedAPI interface {
// GetTerminator returns a transform that will allow the given capture to be terminated
// after a atom
GetTerminator(ctx context.Context, c *path.Capture) (transform.Terminator, error)
// ResolveSynchronization resolve all of the synchronization information for
// the given API
ResolveSynchronization(ctx context.Context, d *Data, c *path.Capture) error
// MutateSubcommands mutates the given Atom calling callback after each subcommand is executed.
MutateSubcommands(ctx context.Context, id api.CmdID, cmd api.Cmd, s *api.State, callback func(*api.State, SubcommandIndex, api.Cmd)) error
}
SynchronizedAPI defines an API that explicitly has multiple threads of execution. This means that replays are not necessarily linear in terms of atoms.