Documentation ¶
Overview ¶
Package sdlspec is an attempt to simulate SDL specifications in GO.
Index ¶
- func ChannelConsumer(die chan Signal, n string, p chan Signal)
- func DefaultMessage(p *Process, s Signal)
- func DieChannel(p *Process) chan Signal
- func DisableLogging()
- func EnableLogging()
- func Execute(ts ...Transmission)
- func Ignored(p *Process, s Signal)
- func MakeBuffer() chan Signal
- func MakeProcess(states func(*Process), name string, die chan Signal) chan<- Signal
- func SendSignalsWithDelay(c chan<- Signal, ss []Signal, ms time.Duration)
- func SetBufferSize(s int)
- func State(p *Process, name string, f func(s Signal)) func()
- type Process
- type Signal
- type Transmission
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChannelConsumer ¶
ChannelConsumer reads all signals at channel p and logs them at std out together with the name of the consumer
func DefaultMessage ¶
DefaultMessage is a helper function for printing a message that it is consumed as a default action at a switch signal.
func DieChannel ¶
DieChannel returns the channel for the termination of the process.
func Ignored ¶
Ignored is a helper function to print a message for ignored (consumed) messages. It is placed within the default section of a switch of a state. It prints only when Logging is enabled.
func MakeBuffer ¶
func MakeBuffer() chan Signal
MakeBuffer creates and returns a buffer for asynchronous communication Buffersize is defined by SetBufferSize
func MakeProcess ¶
MakeProcess accepts a process definition and a name. It also receives a signal channel used for termination. All processes sharing the same die channel will terminate when close(die) is called. It initializes the buffer where the process is reading from. It returns the buffer of the process so that other processes can write to it.
func SendSignalsWithDelay ¶
SendSignalsWithDelay sends all the signals in the signal list to channel c with a delay between each transmission equal to ms milliseconds
func SetBufferSize ¶
func SetBufferSize(s int)
SetBufferSize sets the size of process buffers. Default is 100
Types ¶
type Process ¶
type Process struct {
// contains filtered or unexported fields
}
Process is a type encapsulating the buffer of a process and the name of a process.
type Signal ¶
type Signal interface{}
Signal is the main structure communicated on channels. It can be any type.
type Transmission ¶
Transmission is used for simulations. Defines a delay in ms, after which the signal is sent to the receiver channel. Executed with the Execute method for one Trasmission or with the Execute function for a variant number of Transmissions.
func (Transmission) Execute ¶
func (t Transmission) Execute()
Execute executes a single Transmission.