goChan

package module
v0.0.0-...-d2bb7a0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2023 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(maxTime int)

Function to initialize the tracer. @return: nil

func PostDefault

func PostDefault()

Function to add at the beginning of a select default body.

func PreSelect

func PreSelect(def bool, channels ...PreObj)

Function to add before a select statement. @param def bool: true if the select has a default statement, false otherwise @param channels ...PreObj: list of PreObj to store the cases

func PrintTrace

func PrintTrace()

Function to print the collected trace.

func RunAnalyzer

func RunAnalyzer()

Main function to run the analyzer. The running of the analyzer locks tracesLock for the total duration of its runtime, to prevent go-routines, that are still running when the main function terminated (and therefore would normally also be terminated) to alter the trace.

func SpawnPost

func SpawnPost(numRut uint32)

Function to call after the creation of a new routine in the new routine @param numRut uint32: id of the new routine

func SpawnPre

func SpawnPre() uint32

Function to call before the creation of a new routine in the old routine @return id of the new routine

Types

type Chan

type Chan[T any] struct {
	// contains filtered or unexported fields
}

Struct to implement a drop in replacement for a channel @field c chan Message[T]: channel to send a message @field id uint32: id for the channel @field capacity: max size of the channel

func NewChan

func NewChan[T any](size int) Chan[T]

Function to create a new channel object. This object can be used as a drop in replacement for a chan T. @param size int: size of the channel, 0 for un-buffered channel @return Chan[T]: channel object

func (Chan[T]) Close

func (ch Chan[T]) Close()

Function as drop-in replacement for closing a channel.

func (Chan[T]) GetChan

func (ch Chan[T]) GetChan() chan Message[T]

Getter for the chan field of a Chan object. @receiver *Chan[T] @return chan Message[T]: chan field of channel

func (Chan[T]) GetId

func (ch Chan[T]) GetId() uint32

Getter fir the id field of a Chan object @receiver *Chan[T] @return uint32: id of the Chan

func (Chan[T]) GetIdPre

func (ch Chan[T]) GetIdPre(receive bool) PreObj

Function to create a PreObj object from a Chan used with select. @param receive bool: true, if the select case is a channel receive, false if it is a send @return PreObj: the created preObj object

func (Chan[T]) Post

func (ch Chan[T]) Post(receive bool, message Message[T])

Function to add at the beginning of a select case body. &param receive bool: true, if the case was started with a receive false if with a send @param message Message[T]: message wich was send over the channel

func (Chan[T]) Receive

func (ch Chan[T]) Receive() T

Function as drop-in replacement for <-ch.c. @receiver: *Chan[T] @return T: received value

func (Chan[T]) ReceiveOk

func (ch Chan[T]) ReceiveOk() (T, bool)

Function as drop-in replacement for a, ok := <-ch.c. @receiver: *Chan[T] @return T: received value

func (Chan[T]) Send

func (ch Chan[T]) Send(val T)

Function as drop-in replacements for ch.c <- T. @receiver: *Chan[T] @param: val T: message to send over the channel

type Message

type Message[T any] struct {
	// contains filtered or unexported fields
}

Struct for message to send by Chan object @field info T: actual message to send @field sender uint32: id of the sender @field senderTimestamp: timestamp when the message was send

func BuildMessage

func BuildMessage[T any](info T) Message[T]

Funktion to create a message. This function is mainly used, when sending a message in a select statement @param info T: info to send @return Message[T]: message object wich can be send

func (*Message[T]) GetInfo

func (m *Message[T]) GetInfo() T

Function to get the info field from a message. @receiver *Message[T] @return T: info field of the message

func (*Message[T]) GetInfoOk

func (m *Message[T]) GetInfoOk() (T, bool)

Function to get the info field from a message which was received by a, ok := <- c. @receiver *Message[T] @return T: info field of the message @return bool: true, if channel was open, false otherwise

type Mutex

type Mutex struct {
	// contains filtered or unexported fields
}

Struct to implement a mutex. Is used as drop-in replacement for sync.Mutex @field mu *sync.Mutex: actual mutex to perform lock and unlock operations @field id uint32: id of the mutex

func NewMutex

func NewMutex() Mutex

Function to create and initialize a new Mutex

func (*Mutex) Lock

func (m *Mutex) Lock()

Function to lock a Mutex. @receiver *Mutex

func (*Mutex) TryLock

func (m *Mutex) TryLock() bool

Function to try-lock a Mutex. @receiver *Mutex @return bool: true if lock was successful, false otherwise

func (*Mutex) Unlock

func (m *Mutex) Unlock()

Function to unlock a Mutex. @receiver *Mutex

type PreObj

type PreObj struct {
	// contains filtered or unexported fields
}

Struct to save a Chan with id. Used to store channel cases in select. @field id uint32: id of the Chan @field chanCreation string: pos of the creation of the chan @field receive bool: true, if the select case is a channel receive, false if it is a send

type RWMutex

type RWMutex struct {
	// contains filtered or unexported fields
}

Struct to implement a rw-mutex. Is used as drop-in replacement for sync.RWMutex @field mu *sync.RWMutex: actual rw-mutex to perform lock and unlock operations @field id uint32: id of the mutex

func NewRWMutex

func NewRWMutex() RWMutex

Function to create and initialize a new RWMutex @return RWMutex: new RWMutex object

func (*RWMutex) Lock

func (m *RWMutex) Lock()

Function to lock a RWMutex. @receiver *RWMutex

func (*RWMutex) RLock

func (m *RWMutex) RLock()

Function to r-lock a RWMutex. @receiver *RWMutex

func (*RWMutex) RUnlock

func (m *RWMutex) RUnlock()

Function to r-unlock a RWMutex. @receiver *RWMutex

func (*RWMutex) TryLock

func (m *RWMutex) TryLock() bool

Function to try-lock a Mutex. @receiver *RWMutex @return bool: true if lock was successful, false otherwise

func (*RWMutex) TryRLock

func (m *RWMutex) TryRLock() bool

Function to try-r-lock a Mutex. @receiver *RWMutex @return bool: true if lock was successful, false otherwise

func (*RWMutex) Unlock

func (m *RWMutex) Unlock()

Function to unlock a RWMutex. @receiver *RWMutex

type TraceClose

type TraceClose struct {
	// contains filtered or unexported fields
}

Struct for a close in the trace. @field postion string: string describing the position of the creation in code @field timestamp uint32: timestamp of the creation of the trace object @field chanId uint32: id of the Chan @field chanCreation string: pos of the creation of the chan

func (*TraceClose) GetTimestamp

func (tc *TraceClose) GetTimestamp() uint32

Function to return the timestamp @return uint32: timestamp

func (*TraceClose) PrintElement

func (tc *TraceClose) PrintElement()

Function to print the close trace element @receiver *TraceClose

type TraceDefault

type TraceDefault struct {
	// contains filtered or unexported fields
}

Struct for a default in the trace. @field postion string: string describing the position of the creation in code @field timestamp uint32: timestamp of the creation of the trace object

func (*TraceDefault) GetTimestamp

func (td *TraceDefault) GetTimestamp() uint32

Function to return the timestamp @return uint32: timestamp

func (*TraceDefault) PrintElement

func (td *TraceDefault) PrintElement()

Function to print the default trace element @receiver *TraceDefault

type TraceElement

type TraceElement interface {
	GetTimestamp() uint32
	PrintElement()
}

Interface for a trace element. @signature PrintElement(): function to print the element

type TraceLock

type TraceLock struct {
	// contains filtered or unexported fields
}

Struct for a lock in the trace. @field postion string: string describing the position of the creation in code @field timestamp uint32: timestamp of the creation of the trace object @field lockId uint32: id of the Mutex @field mutexCreation string: position of the creation of the mutex @field try bool: true if it is a try-lock, false otherwise @field read bool: true if it is a r-lock, false otherwise @field suc bool: true if the operation was successful, false otherwise (only try)

func (*TraceLock) GetTimestamp

func (tl *TraceLock) GetTimestamp() uint32

Function to return the timestamp @return uint32: timestamp

func (*TraceLock) PrintElement

func (tl *TraceLock) PrintElement()

Function to print the lock trace element @receiver *TraceLock

type TracePost

type TracePost struct {
	// contains filtered or unexported fields
}

Struct for a post in the trace. @field postion string: string describing the position of the creation in code @field timestamp uint32: timestamp of the creation of the trace object @field chanId uint32: id of the Chan @field chanCreation string: pos of the creation of the chan @field send bool: true if it is a preSend, false otherwise @field senderId: id of the sender of the message @field senderTimestamp: timestamp of the sender at send @field noComs: if send, number of send on the channel, if read number of read (after the post)

func (*TracePost) GetTimestamp

func (tp *TracePost) GetTimestamp() uint32

Function to return the timestamp @return uint32: timestamp

func (*TracePost) PrintElement

func (tp *TracePost) PrintElement()

Function to print the post trace element @receiver *TracePost

type TracePre

type TracePre struct {
	// contains filtered or unexported fields
}

Struct for a pre in the trace. @field postion string: string describing the position of the creation in code @field timestamp uint32: timestamp of the creation of the trace object @field chanId uint32: id of the Chan @field chanCreation string: pos of the creation of the chan @field send bool: true if it is a preSend, false otherwise

func (*TracePre) GetTimestamp

func (tp *TracePre) GetTimestamp() uint32

Function to return the timestamp @return uint32: timestamp

func (*TracePre) PrintElement

func (tp *TracePre) PrintElement()

Function to print the pre trace element @receiver *TracePre

type TracePreSelect

type TracePreSelect struct {
	// contains filtered or unexported fields
}

Struct for a preSelect in the trace. @field postion string: string describing the position of the creation in code @field timestamp uint32: timestamp of the creation of the trace object @field chanIds []PreObj: list of channels in cases @field def bool: true if the select has a default case, false otherwise

func (*TracePreSelect) GetTimestamp

func (tps *TracePreSelect) GetTimestamp() uint32

Function to return the timestamp @return uint32: timestamp

func (*TracePreSelect) PrintElement

func (tps *TracePreSelect) PrintElement()

Function to print the preSelect trace element @receiver *TracePreSelect

type TraceSignal

type TraceSignal struct {
	// contains filtered or unexported fields
}

Struct for a signal in the trace. @field postion string: string describing the position of the creation in code @field timestamp uint32: timestamp of the creation of the trace object @field routine uint32: id of the new routine

func (*TraceSignal) GetTimestamp

func (ts *TraceSignal) GetTimestamp() uint32

Function to return the timestamp @return uint32: timestamp

func (*TraceSignal) PrintElement

func (ts *TraceSignal) PrintElement()

Function to print the signal trace element @receiver *TraceSignal

type TraceUnlock

type TraceUnlock struct {
	// contains filtered or unexported fields
}

Struct for a unlock in the trace. @field postion string: string describing the position of the creation in code @field timestamp uint32: timestamp of the creation of the trace object @field lockId uint32: id of the Mutex @field mutexCreation string: position of the creation of the mutex

func (*TraceUnlock) GetTimestamp

func (tu *TraceUnlock) GetTimestamp() uint32

Function to return the timestamp @return uint32: timestamp

func (*TraceUnlock) PrintElement

func (tu *TraceUnlock) PrintElement()

Function to print the unlock trace element @receiver *TraceUnlock

type TraceWait

type TraceWait struct {
	// contains filtered or unexported fields
}

Struct for a wait in the trace. @field postion string: string describing the position of the creation in code @field timestamp uint32: timestamp of the creation of the trace object @field routine uint32: id of the routine

func (*TraceWait) GetTimestamp

func (ts *TraceWait) GetTimestamp() uint32

Function to return the timestamp @return uint32: timestamp

func (*TraceWait) PrintElement

func (tw *TraceWait) PrintElement()

Function to print the wait trace element @receiver *TraceWait

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL