Documentation ¶
Index ¶
- type StopMode
- type ThreadTracker
- func (t *ThreadTracker) NumActiveThreads() uint64
- func (t *ThreadTracker) Stop(stopMode StopMode)
- func (t *ThreadTracker) TriggerGoroutine(fn func(inputs []interface{}), inputs []interface{}) error
- func (t *ThreadTracker) TriggerGoroutineWithDefers(deferredFns []func(), fn func(inputs []interface{}), inputs []interface{}) error
- func (t *ThreadTracker) Wait()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type StopMode ¶
type StopMode uint8
StopMode represents the behavior of the threadTracker once it has been stopped
type ThreadTracker ¶
type ThreadTracker struct {
// contains filtered or unexported fields
}
ThreadTracker allows you to easily manage goroutines
func MakeThreadTracker ¶
func MakeThreadTracker() *ThreadTracker
MakeThreadTracker is a factory method for ThreadTracker
func (*ThreadTracker) NumActiveThreads ¶
func (t *ThreadTracker) NumActiveThreads() uint64
NumActiveThreads fetches the number of active threads managed by this threadTracker
func (*ThreadTracker) Stop ¶
func (t *ThreadTracker) Stop(stopMode StopMode)
Stop prevents this threadTracker from accepting any more threads
func (*ThreadTracker) TriggerGoroutine ¶
func (t *ThreadTracker) TriggerGoroutine(fn func(inputs []interface{}), inputs []interface{}) error
TriggerGoroutine initiates a new goroutine while tracking it typical usage 1:
threadTracker.TriggerGoroutine(func(inputs []interface{}) { fmt.Printf("Hello %s\n", "World") })
typical usage 2:
threadTracker.TriggerGoroutine(func(inputs []interface{}) { fmt.Printf("Hello %s\n", inputs[0]) }, "World")
func (*ThreadTracker) TriggerGoroutineWithDefers ¶
func (t *ThreadTracker) TriggerGoroutineWithDefers(deferredFns []func(), fn func(inputs []interface{}), inputs []interface{}) error
TriggerGoroutineWithDefers initiates a new goroutine while tracking it typical usage:
threadTracker.TriggerGoroutineWithDefers([]func(){ func() { fmt.Printf("this should appear third\n") }, func() { fmt.Printf("this should appear second\n") }, }, func(inputs []interface{}) { fmt.Printf("Hello %s -- this should appear first\n", "World") })
Click to show internal directories.
Click to hide internal directories.