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
b69e80d8
Commit
b69e80d8
authored
Nov 06, 2008
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
runtime support for default in select.
assumes cas->send == 2 for default case. R=ken OCL=18628 CL=18628
parent
d6a7cefd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
2 deletions
+13
-2
chan.c
src/runtime/chan.c
+13
-2
No files found.
src/runtime/chan.c
View file @
b69e80d8
...
@@ -52,7 +52,7 @@ struct Scase
...
@@ -52,7 +52,7 @@ struct Scase
{
{
Hchan
*
chan
;
// chan
Hchan
*
chan
;
// chan
byte
*
pc
;
// return pc
byte
*
pc
;
// return pc
uint16
send
;
// 0-recv 1-send
uint16
send
;
// 0-recv 1-send
2-default
uint16
so
;
// vararg of selected bool
uint16
so
;
// vararg of selected bool
union
{
union
{
byte
elem
[
8
];
// element (send)
byte
elem
[
8
];
// element (send)
...
@@ -504,7 +504,7 @@ void
...
@@ -504,7 +504,7 @@ void
sys
·
selectgo
(
Select
*
sel
)
sys
·
selectgo
(
Select
*
sel
)
{
{
uint32
p
,
o
,
i
;
uint32
p
,
o
,
i
;
Scase
*
cas
;
Scase
*
cas
,
*
dfl
;
Hchan
*
c
;
Hchan
*
c
;
SudoG
*
sg
;
SudoG
*
sg
;
G
*
gp
;
G
*
gp
;
...
@@ -542,8 +542,13 @@ sys·selectgo(Select *sel)
...
@@ -542,8 +542,13 @@ sys·selectgo(Select *sel)
lock
(
&
chanlock
);
lock
(
&
chanlock
);
// pass 1 - look for something already waiting
// pass 1 - look for something already waiting
dfl
=
nil
;
for
(
i
=
0
;
i
<
sel
->
ncase
;
i
++
)
{
for
(
i
=
0
;
i
<
sel
->
ncase
;
i
++
)
{
cas
=
&
sel
->
scase
[
o
];
cas
=
&
sel
->
scase
[
o
];
if
(
cas
->
send
==
2
)
{
// default
dfl
=
cas
;
continue
;
}
c
=
cas
->
chan
;
c
=
cas
->
chan
;
if
(
c
->
dataqsiz
>
0
)
{
if
(
c
->
dataqsiz
>
0
)
{
if
(
cas
->
send
)
{
if
(
cas
->
send
)
{
...
@@ -570,6 +575,12 @@ sys·selectgo(Select *sel)
...
@@ -570,6 +575,12 @@ sys·selectgo(Select *sel)
o
-=
sel
->
ncase
;
o
-=
sel
->
ncase
;
}
}
if
(
dfl
!=
nil
)
{
cas
=
dfl
;
goto
retc
;
}
// pass 2 - enqueue on all chans
// pass 2 - enqueue on all chans
for
(
i
=
0
;
i
<
sel
->
ncase
;
i
++
)
{
for
(
i
=
0
;
i
<
sel
->
ncase
;
i
++
)
{
cas
=
&
sel
->
scase
[
o
];
cas
=
&
sel
->
scase
[
o
];
...
...
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