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
a6af4843
Commit
a6af4843
authored
Nov 06, 2008
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more runtime support for chan select default
R=ken OCL=18630 CL=18630
parent
b69e80d8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
1 deletion
+39
-1
chan.c
src/runtime/chan.c
+39
-1
No files found.
src/runtime/chan.c
View file @
a6af4843
...
...
@@ -469,7 +469,7 @@ sys·selectrecv(Select *sel, Hchan *c, ...)
i
=
sel
->
ncase
;
if
(
i
>=
sel
->
tcase
)
throw
(
"select
send
: too many cases"
);
throw
(
"select
recv
: too many cases"
);
sel
->
ncase
=
i
+
1
;
cas
=
&
sel
->
scase
[
i
];
...
...
@@ -497,6 +497,44 @@ sys·selectrecv(Select *sel, Hchan *c, ...)
}
}
void
sys
·
selectdefault
(
Select
*
sel
)
{
int32
i
,
eo
;
Scase
*
cas
;
Hchan
*
c
;
c
=
nil
;
i
=
sel
->
ncase
;
if
(
i
>=
sel
->
tcase
)
throw
(
"selectdefault: too many cases"
);
sel
->
ncase
=
i
+
1
;
cas
=
&
sel
->
scase
[
i
];
cas
->
pc
=
sys
·
getcallerpc
(
&
sel
);
cas
->
chan
=
c
;
eo
=
rnd
(
sizeof
(
sel
),
sizeof
(
c
));
eo
=
rnd
(
eo
+
sizeof
(
c
),
sizeof
(
byte
*
));
cas
->
so
=
rnd
(
eo
+
sizeof
(
byte
*
),
1
);
cas
->
send
=
2
;
cas
->
u
.
elemp
=
*
(
byte
**
)((
byte
*
)
&
sel
+
eo
);
if
(
debug
)
{
prints
(
"newselect s="
);
sys
·
printpointer
(
sel
);
prints
(
" pc="
);
sys
·
printpointer
(
cas
->
pc
);
prints
(
" chan="
);
sys
·
printpointer
(
cas
->
chan
);
prints
(
" so="
);
sys
·
printint
(
cas
->
so
);
prints
(
" send="
);
sys
·
printint
(
cas
->
send
);
prints
(
"
\n
"
);
}
}
uint32
xxx
=
0
;
// selectgo(sel *byte);
...
...
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