File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ public function add(int $delta = 1): void
34
34
}
35
35
$ count = $ this ->count + $ delta ;
36
36
if ($ count < 0 ) {
37
- throw new InvalidArgumentException ('negative WaitGroup counter ' );
37
+ throw new InvalidArgumentException ('WaitGroup misuse: negative counter ' );
38
38
}
39
39
$ this ->count = $ count ;
40
40
}
@@ -43,7 +43,7 @@ public function done(): void
43
43
{
44
44
$ count = $ this ->count - 1 ;
45
45
if ($ count < 0 ) {
46
- throw new BadMethodCallException ('negative WaitGroup counter ' );
46
+ throw new BadMethodCallException ('WaitGroup misuse: negative counter ' );
47
47
}
48
48
$ this ->count = $ count ;
49
49
if ($ count === 0 && $ this ->waiting ) {
@@ -53,6 +53,9 @@ public function done(): void
53
53
54
54
public function wait (float $ timeout = -1 ): bool
55
55
{
56
+ if ($ this ->waiting ) {
57
+ throw new BadMethodCallException ('WaitGroup misuse: reused before previous wait has returned ' );
58
+ }
56
59
if ($ this ->count > 0 ) {
57
60
$ this ->waiting = true ;
58
61
$ done = $ this ->chan ->pop ($ timeout );
You can’t perform that action at this time.
0 commit comments