Documentation ¶
Overview ¶
Example ¶
d := g.New(10) // go 1 var res int d.Go(func() { fmt.Println("1 + 1 = ?") res = 1 + 1 }, func() { fmt.Println(res) }) d.Cb(<-d.ChanCb) // go 2 d.Go(func() { fmt.Print("My name is ") }, func() { fmt.Println("Leaf") }) d.Close()
Output: 1 + 1 = ? 2 My name is Leaf
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Go ¶
type Go struct { ChanCb chan func() // contains filtered or unexported fields }
one Go per goroutine (goroutine not safe)
func (*Go) NewLinearContext ¶
func (g *Go) NewLinearContext() *LinearContext
type LinearContext ¶
type LinearContext struct {
// contains filtered or unexported fields
}
Example ¶
d := g.New(10) // parallel d.Go(func() { time.Sleep(time.Second / 2) fmt.Println("1") }, nil) d.Go(func() { fmt.Println("2") }, nil) d.Cb(<-d.ChanCb) d.Cb(<-d.ChanCb) // linear c := d.NewLinearContext() c.Go(func() { time.Sleep(time.Second / 2) fmt.Println("1") }, nil) c.Go(func() { fmt.Println("2") }, nil) d.Close()
Output: 2 1 1 2
func (*LinearContext) Go ¶
func (c *LinearContext) Go(f func(), cb func())
Click to show internal directories.
Click to hide internal directories.