10 examples of 'wait group golang' in Go

Every line of 'wait group golang' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Go code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
92func (g *Group) Wait() error {
93 g.wg.Wait()
94 g.mu.Lock()
95 defer g.mu.Unlock()
96 errors := g.errors
97 l := len(errors)
98 if l == 0 {
99 return nil
100 }
101 if l == 1 {
102 return errors[0]
103 }
104 return errors
105}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

7func Group(chans ...<-chan struct{}) <-chan struct{} {
8 var wg sync.WaitGroup
9
10 for _, c := range chans {
11 wg.Add(1)
12 go func(c <-chan struct{}) {
13 for range c {
14 }
15 wg.Done()
16 }(c)
17 }
18
19 done := make(chan struct{})
20 go func() {
21 wg.Wait()
22 close(done)
23 }()
24
25 return done
26}
227func (s *Status) Group(v ...interface{}) *Group {
228 name := fmt.Sprint(v...)
229 s.mu.Lock()
230 if s.groups == nil {
231 s.groups = make(map[string]*Group)
232 }
233 if s.groups[name] == nil {
234 s.groups[name] = &Group{status: s, value: Value{Title: name}}
235 }
236 g := s.groups[name]
237 s.mu.Unlock()
238 s.notify()
239 return g
240}
111func (g *Group) Wait() error {
112 if g.ch != nil {
113 for _, f := range g.chs {
114 g.ch <- f
115 }
116 }
117 g.wg.Wait()
118 if g.ch != nil {
119 close(g.ch) // let all receiver exit
120 }
121 if g.cancel != nil {
122 g.cancel()
123 }
124 return g.err
125}
168func (d *indexer) Wait() error {
169 d.wg.Wait()
170 return d.err.Load()
171}
90func Wait(sig ...os.Signal) os.Signal {
91 c := make(chan os.Signal, 1)
92 if len(sig) == 0 {
93 signal.Notify(c, syscall.SIGINT, syscall.SIGTERM)
94 } else {
95 signal.Notify(c, sig...)
96 }
97 return <-c
98}
126func (c *MarathonClient) UpdateGroup(group *Group, wait bool) (*Group, error) {
127 log.Info("Update Group '%s', wait = %v", group.GroupID, wait)
128 result := new(DeploymentID)
129 resp := c.http.HttpPut(c.marathonUrl(API_GROUPS), group, result)
130
131 if resp.Error != nil {
132 if resp.Error == httpclient.ErrorMessage {
133 if resp.Status == 422 {
134 return nil, ErrorGroupAppExists
135 }
136 }
137 return nil, resp.Error
138 }
139 if wait {
140 if err := c.WaitForDeployment(result.DeploymentID, c.determineTimeout(nil)); err != nil {
141 return nil, err
142 }
143 }
144 // Get the latest version of the application to return
145 return c.GetGroup(group.GroupID)
146}
148func (p *process) groupSignal(s syscall.Signal) error {
149 if pid := p.pid; pid > 0 {
150 return syscall.Kill(-pid, s)
151 }
152
153 return nil
154}
448func Wait() {
449 <-allDoneChan
450
451 glog.Printf("[ghttp] %d: all servers shutdown", gproc.Pid())
452}
15func Wait(clean func()) {
16 finish := make(chan bool)
17
18 c := make(chan os.Signal, 1)
19 signal.Notify(c, os.Interrupt)
20 go func() {
21 // sig is a ^C, handle it
22 <-c
23 clean()
24 finish <- true
25 }()
26
27 <-finish
28}

Related snippets