Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
2d9ff407
Commit
2d9ff407
authored
Jul 14, 2008
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chan asynch
SVN=127121
parent
fbab6ae9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
5 deletions
+50
-5
src/cmd/gc/go.y
src/cmd/gc/go.y
+5
-0
src/runtime/chan.c
src/runtime/chan.c
+45
-5
No files found.
src/cmd/gc/go.y
View file @
2d9ff407
...
...
@@ -706,6 +706,11 @@ pexpr:
$$
=
nod
(
ONEW
,
N
,
N
);
$$->
type
=
ptrto
($
3
);
}
|
LNEW
'('
type
','
expr_list
')'
{
$$
=
nod
(
ONEW
,
$
5
,
N
);
$$->
type
=
ptrto
($
3
);
}
|
fnliteral
|
'['
expr_list
']'
{
...
...
src/runtime/chan.c
View file @
2d9ff407
...
...
@@ -26,7 +26,7 @@ struct Hchan
struct
Link
{
Link
*
link
;
byte
data
[
8
];
byte
elem
[
8
];
};
// newchan(elemsize uint32, elemalg uint32, hint uint32) (hchan *chan any);
...
...
@@ -124,7 +124,17 @@ sys·chansend(Hchan* c, ...)
return
;
asynch:
throw
(
"sys·chansend: asynch not yet"
);
while
(
c
->
qcount
>=
c
->
dataqsiz
)
{
g
->
status
=
Gwaiting
;
enqueue
(
&
c
->
sendq
,
g
);
sys
·
gosched
();
}
c
->
elemalg
->
copy
(
c
->
elemsize
,
c
->
senddataq
->
elem
,
ae
);
c
->
senddataq
=
c
->
senddataq
->
link
;
c
->
qcount
++
;
gr
=
dequeue
(
&
c
->
recvq
);
if
(
gr
!=
nil
)
gr
->
status
=
Grunnable
;
}
// chanrecv1(hchan *chan any) (elem any);
...
...
@@ -156,7 +166,17 @@ sys·chanrecv1(Hchan* c, ...)
return
;
asynch:
throw
(
"sys·chanrecv1: asynch not yet"
);
while
(
c
->
qcount
<=
0
)
{
g
->
status
=
Gwaiting
;
enqueue
(
&
c
->
recvq
,
g
);
sys
·
gosched
();
}
c
->
elemalg
->
copy
(
c
->
elemsize
,
ae
,
c
->
recvdataq
->
elem
);
c
->
recvdataq
=
c
->
recvdataq
->
link
;
c
->
qcount
--
;
gs
=
dequeue
(
&
c
->
sendq
);
if
(
gs
!=
nil
)
gs
->
status
=
Grunnable
;
}
// chanrecv2(hchan *chan any) (elem any, pres bool);
...
...
@@ -164,6 +184,7 @@ void
sys
·
chanrecv2
(
Hchan
*
c
,
...)
{
byte
*
ae
,
*
ap
;
G
*
gs
;
ae
=
(
byte
*
)
&
c
+
c
->
eo
;
ap
=
(
byte
*
)
&
c
+
c
->
po
;
...
...
@@ -174,8 +195,27 @@ sys·chanrecv2(Hchan* c, ...)
}
if
(
c
->
dataqsiz
>
0
)
goto
asynch
;
throw
(
"sys·chanrecv2: synch not yet"
);
gs
=
dequeue
(
&
c
->
sendq
);
if
(
gs
!=
nil
)
{
c
->
elemalg
->
copy
(
c
->
elemsize
,
ae
,
gs
->
elem
);
gs
->
status
=
Grunnable
;
*
ap
=
true
;
return
;
}
*
ap
=
false
;
return
;
asynch:
throw
(
"sys·chanrecv2: asynch not yet"
);
if
(
c
->
qcount
<=
0
)
{
*
ap
=
false
;
return
;
}
c
->
elemalg
->
copy
(
c
->
elemsize
,
ae
,
c
->
recvdataq
->
elem
);
c
->
recvdataq
=
c
->
recvdataq
->
link
;
c
->
qcount
--
;
gs
=
dequeue
(
&
c
->
sendq
);
if
(
gs
!=
nil
)
gs
->
status
=
Grunnable
;
*
ap
=
true
;
}
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