blob: 2db10be23549b96b55c4d5a14c71fe484cb59a45 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Test case for issue 3106: Better synchronization of
// parser after certain syntax errors.
package main
func f() {
var m Mutex
c := MakeCond(&m)
percent := 0
const step = 10
for i := 0; i < 5; i++ {
go func() {
for {
// Emulates some useful work.
time.Sleep(1e8)
m.Lock()
defer
if /* ERROR "expected ';', found 'if'" */ percent == 100 {
m.Unlock()
break
}
percent++
if percent % step == 0 {
//c.Signal()
}
m.Unlock()
}
}()
}
for {
m.Lock()
if percent == 0 || percent % step != 0 {
c.Wait()
}
fmt.Print(",")
if percent == 100 {
m.Unlock()
break
}
m.Unlock()
}
}
|