Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
3f19d8ae
Commit
3f19d8ae
authored
Aug 03, 2010
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gc: empty select
R=ken2 CC=golang-dev
https://golang.org/cl/1871057
parent
585eae3b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
37 deletions
+32
-37
select.c
src/cmd/gc/select.c
+1
-3
chan.c
src/pkg/runtime/chan.c
+5
-3
select3.go
test/chan/select3.go
+26
-31
No files found.
src/cmd/gc/select.c
View file @
3f19d8ae
...
...
@@ -68,8 +68,6 @@ typecheckselect(Node *sel)
typechecklist
(
ncase
->
nbody
,
Etop
);
}
sel
->
xoffset
=
count
;
if
(
count
==
0
)
yyerror
(
"empty select"
);
lineno
=
lno
;
}
...
...
@@ -91,7 +89,7 @@ walkselect(Node *sel)
typecheck
(
&
r
,
Etop
);
init
=
list
(
init
,
r
);
if
(
sel
->
list
==
nil
)
if
(
sel
->
list
==
nil
&&
sel
->
xoffset
!=
0
)
fatal
(
"double walkselect"
);
// already rewrote
// register cases
...
...
src/pkg/runtime/chan.c
View file @
3f19d8ae
...
...
@@ -631,9 +631,11 @@ void
printf
(
"select: sel=%p
\n
"
,
sel
);
if
(
sel
->
ncase
<
2
)
{
if
(
sel
->
ncase
<
1
)
throw
(
"select: no cases"
);
// make special case of one.
if
(
sel
->
ncase
<
1
)
{
g
->
status
=
Gwaiting
;
// forever
gosched
();
}
// TODO: make special case of one.
}
// select a (relative) prime
...
...
test/chan/select3.go
View file @
3f19d8ae
...
...
@@ -112,38 +112,33 @@ func main() {
<-
ch
})
// TODO(gri) remove this if once 6g accepts empty selects
enabled
:=
false
if
enabled
{
// empty selects always block
testBlock
(
always
,
func
()
{
select
{
case
<-
make
(
chan
int
)
:
// remove this once 6g accepts empty selects
}
})
// empty selects always block
testBlock
(
always
,
func
()
{
select
{
}
})
// selects with only nil channels always block
testBlock
(
always
,
func
()
{
select
{
case
<-
nilch
:
unreachable
()
}
})
testBlock
(
always
,
func
()
{
select
{
case
nilch
<-
7
:
unreachable
()
}
})
testBlock
(
always
,
func
()
{
select
{
case
<-
nilch
:
unreachable
()
case
nilch
<-
7
:
unreachable
()
}
})
}
// selects with only nil channels always block
testBlock
(
always
,
func
()
{
select
{
case
<-
nilch
:
unreachable
()
}
})
testBlock
(
always
,
func
()
{
select
{
case
nilch
<-
7
:
unreachable
()
}
})
testBlock
(
always
,
func
()
{
select
{
case
<-
nilch
:
unreachable
()
case
nilch
<-
7
:
unreachable
()
}
})
// selects with non-ready non-nil channels always block
testBlock
(
always
,
func
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment