g0

package
v0.4.42 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2023 License: ISC Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

GoEntityIDs generate IDs for Go Objects

View Source
var GoGroupFactory parl.GoFactory = &goGroupFactory{}

Functions

func NewGoError

func NewGoError(err error, errContext parl.GoErrorContext, g0 parl.Go) (goError parl.GoError)

func NewGoGroup added in v0.4.19

func NewGoGroup(ctx context.Context, onFirstFatal ...parl.GoFatalCallback) (g0 parl.GoGroup)

NewGoGroup returns a stand-alone thread-group with its own error channel. Thread-safe.

  • ctx is not canceled by the thread-group
  • ctx may initiate thread-group Cancel
  • a stand-alone GoGroup thread-group has goGroupParent nil
  • non-fatal and fatal errors from the thread-group’s threads are sent on the GoGroup’s error channel
  • the GoGroup processes Go invocations and thread-exits from its own threads and the threads of its subordinate thread-groups wait-group and that of its parent
  • cancel of the GoGroup’s context signals termination to its own threads and all threads of its subordinate thread-groups
  • the GoGroup’s context is canceled when its provided parent context is canceled or any of its threads invoke the GoGroup’s Cancel method
  • the GoGroup terminates when its error channel closes from all threads in its own thread-group and that of any subordinate thread-groups have exited.

func ThreadInfo added in v0.4.40

func ThreadInfo(t *ThreadData) (s string)

func ThreadLogger added in v0.4.29

func ThreadLogger(goGen parl.GoGen, wg parl.SyncDone, logFn ...func(format string, a ...interface{}))

ThreadLogger waits for a GoGroup, SubGo or SubGroup while printing information on threads that have yet to exit.

  • ThreadLogger is non-blocking and will invoke Done on wg

Usage:

main() {
  var debugWait sync.WaitGroup
  defer debugWait.Wait()
 …
 debugWait.Add(1)
 ThreadLogger(goGroup, &debugWait)

Types

type Go added in v0.4.21

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

Go supports a goroutine executing part of a thread-group. Thread-safe.

  • a single thread exit is handled by Done, delegated to parent, and is deferrable.
  • the Go thread terminates on Done invocation.
  • non-fatal errors are processed by AddError delegated to parent
  • new Go threads are delegated to parent
  • SubGo creates a subordinate thread-group with its own error channel
  • SubGroup creates a subordinate thread-group with FirstFatal mechanic

func (*Go) AddError added in v0.4.21

func (g0 *Go) AddError(err error)

func (*Go) Cancel added in v0.4.21

func (g0 *Go) Cancel()

Cancel cancels the GoGroup

func (*Go) CancelGo added in v0.4.29

func (g0 *Go) CancelGo()

CancelGo signals to this Go thread to exit.

func (*Go) Done added in v0.4.21

func (g0 *Go) Done(errp *error)

Done handles thread exit. Deferrable

func (*Go) G0ID added in v0.4.29

func (gi *Go) G0ID() (id GoEntityID)

func (*Go) Register added in v0.4.21

func (g0 *Go) Register() (g00 parl.Go)

func (*Go) String added in v0.4.29

func (g0 *Go) String() (s string)

g1ID:4:g0.(*g1WaitGroup).Go-g1-thread-group.go:63

func (*Go) SubGo added in v0.4.21

func (g0 *Go) SubGo(onFirstFatal ...parl.GoFatalCallback) (subGo parl.SubGo)

SubGo returns a thread-group without its own error channel but with FirstFatal mechanic

func (*Go) SubGroup added in v0.4.29

func (g0 *Go) SubGroup(onFirstFatal ...parl.GoFatalCallback) (subGroup parl.SubGroup)

SubGroup returns a thread-group with its own error channel.

func (*Go) ThreadData added in v0.4.29

func (g0 *Go) ThreadData() (threadData *ThreadData)

func (*Go) ThreadInfo added in v0.4.29

func (g0 *Go) ThreadInfo() (
	threadID parl.ThreadID,
	createLocation *pruntime.CodeLocation,
	funcLocation *pruntime.CodeLocation,
)

func (*Go) Wait added in v0.4.29

func (g0 *Go) Wait()

Wait awaits exit of this Go thread

type GoEntityID added in v0.4.29

type GoEntityID uint64

GoEntityID is a unique named type for Go objects

func (GoEntityID) String added in v0.4.31

func (gi GoEntityID) String() (s string)

type GoEntityIDer added in v0.4.29

type GoEntityIDer interface {
	G0ID() (id GoEntityID)
}

type GoError added in v0.4.29

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

func (*GoError) Err added in v0.4.29

func (ge *GoError) Err() (err error)

func (*GoError) ErrContext added in v0.4.29

func (ge *GoError) ErrContext() (errContext parl.GoErrorContext)

func (*GoError) Error added in v0.4.29

func (ge *GoError) Error() (message string)

func (*GoError) Go added in v0.4.29

func (ge *GoError) Go() (g0 parl.Go)

func (*GoError) IsFatal added in v0.4.29

func (ge *GoError) IsFatal() (isThreadExit bool)

func (*GoError) IsThreadExit added in v0.4.29

func (ge *GoError) IsThreadExit() (isThreadExit bool)

func (*GoError) String added in v0.4.29

func (ge *GoError) String() (s string)

func (*GoError) Time added in v0.4.29

func (ge *GoError) Time() (when time.Time)

type GoGroup added in v0.4.19

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

GoGroup is a Go thread-group. Thread-safe.

  • GoGroup has its own error channel and waitgroup and no parent thread-group.
  • thread exits are processed by G1Done and the g1WaitGroup
  • the thread-group terminates when its erropr channel closes
  • non-fatal erors are processed by ConsumeError and the error channel
  • new Go threads are handled by the g1WaitGroup
  • SubGroup creates a subordinate thread-group using this threadgroup’s error channel

func (*GoGroup) Add added in v0.4.19

func (g0 *GoGroup) Add(goEntityID GoEntityID, threadData *ThreadData)

Add processes a thread from this or a subordinate thread-group

func (*GoGroup) Ch added in v0.4.20

func (g0 *GoGroup) Ch() (ch <-chan parl.GoError)

func (*GoGroup) ConsumeError added in v0.4.29

func (g0 *GoGroup) ConsumeError(goError parl.GoError)

ConsumeError receives non-fatal errors from a Go thread. Go.AddError delegates to this method

func (*GoGroup) FirstFatal added in v0.4.29

func (g0 *GoGroup) FirstFatal() (firstFatal *parl.OnceWaiterRO)

func (*GoGroup) G0ID added in v0.4.29

func (gi *GoGroup) G0ID() (id GoEntityID)

func (*GoGroup) Go added in v0.4.29

func (g0 *GoGroup) Go() (g1 parl.Go)

Go returns a parl.Go thread-features object

  • Go is invoked by a g0-package consumer
  • the Go return value is to be used as a function argument in a go-statement function-call launching a goroutine thread

func (*GoGroup) GoDone added in v0.4.29

func (g0 *GoGroup) GoDone(thread parl.Go, err error)

Done receives thread exits from threads in subordinate thread-groups

func (*GoGroup) String added in v0.4.20

func (g0 *GoGroup) String() (s string)

g1Group#3threads:1(1)g0.TestNewG1Group-g1-group_test.go:60

func (*GoGroup) SubGo added in v0.4.29

func (g0 *GoGroup) SubGo(onFirstFatal ...parl.GoFatalCallback) (g1 parl.SubGo)

newSubGo returns a subordinate thread-group witthout an error channel. Thread-safe.

  • a SubGo has goGroupParent non-nil and isSubGo true
  • the SubGo thread’s fatal and non-fatal errors are forwarded to its parent
  • SubGo has FirstFatal mechanic but no error channel of its own.
  • the SubGo’s Go invocations and thread-exits are processed by the SubGo’s wait-group and the thread-group of its parent
  • cancel of the SubGo’s context signals termination to its own threads and all threads of its subordinate thread-groups
  • the SubGo’s context is canceled when its parent’s context is canceled or any of its threads invoke the SubGo’s Cancel method
  • the SubGo thread-group terminates when all threads in its own thread-group and that of any subordinate thread-groups have exited.

func (*GoGroup) SubGroup added in v0.4.29

func (g0 *GoGroup) SubGroup(onFirstFatal ...parl.GoFatalCallback) (g1 parl.SubGroup)

newSubGroup returns a subordinate thread-group with an error channel handling fatal errors only. Thread-safe.

  • a SubGroup has goGroupParent non-nil and isSubGo false
  • fatal errors from the SubGroup’s threads are sent on its own error channel
  • non-fatal errors from the SubGroup’s threads are forwarded to the parent
  • the SubGroup’s Go invocations and thread-exits are processed in the SubGroup’s wait-group and that of its parent
  • cancel of the SubGroup’s context signals termination to its own threads and all threads of its subordinate thread-groups
  • the SubGroup’s context is canceled when its parent’s context is canceled or any of its threads invoke the SubGroup’s Cancel method
  • SubGroup thread-group terminates when its error channel closes after all of its threads and threads of its subordinate thread-groups have exited.

func (*GoGroup) UpdateThread added in v0.4.29

func (g0 *GoGroup) UpdateThread(goEntityID GoEntityID, threadData *ThreadData)

func (*GoGroup) Wait added in v0.4.19

func (g0 *GoGroup) Wait()

type ThreadData added in v0.4.29

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

ThreadData contains identifiable information about a running thread.

  • ThreadData does not have initialization

func (*ThreadData) Get added in v0.4.29

func (td *ThreadData) Get() (threadID parl.ThreadID, createLocation pruntime.CodeLocation,
	funcLocation pruntime.CodeLocation)

func (*ThreadData) SetCreator added in v0.4.29

func (td *ThreadData) SetCreator(cl *pruntime.CodeLocation)

SetCreator gets preliminary Go identifier: the line invoking Go()

func (*ThreadData) ThreadID added in v0.4.29

func (td *ThreadData) ThreadID() (threadID parl.ThreadID)

threadID is the ID of the running thread

func (*ThreadData) Update added in v0.4.29

func (td *ThreadData) Update(stack parl.Stack)

Update populates this object from a stack trace.

type ThreadSafeThreadData added in v0.4.37

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

ThreadSafeThreadData controls access to a ThreadData object making it thread-safe.

  • ThreadSafeThreadData does not have initialization
  • haveThreadID indicates whether data is present

func (*ThreadSafeThreadData) Get added in v0.4.37

func (tw *ThreadSafeThreadData) Get() (thread *ThreadData)

Get returns a clone of the wrapped ThreadData object.

func (*ThreadSafeThreadData) HaveThreadID added in v0.4.37

func (tw *ThreadSafeThreadData) HaveThreadID() (haveThreadID bool)

HaveThreadID indicates whether Update has been invoked on this ThreadDataWrap object.

func (*ThreadSafeThreadData) SetCreator added in v0.4.37

func (tw *ThreadSafeThreadData) SetCreator(cl *pruntime.CodeLocation)

SetCreator gets preliminary Go identifier: the line invoking Go().

func (*ThreadSafeThreadData) ThreadID added in v0.4.37

func (tw *ThreadSafeThreadData) ThreadID() (threadID parl.ThreadID)

ThreadID returns the thread id of the running thread or zero if thread ID is missing.

func (*ThreadSafeThreadData) Update added in v0.4.37

func (tw *ThreadSafeThreadData) Update(stack parl.Stack)

Update populates the wrapped ThreadData from the stack trace.

Jump to

Keyboard shortcuts

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