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
00ad47f9
Commit
00ad47f9
authored
Jun 29, 2010
by
Vinu Rajashekhar
Committed by
Ian Lance Taylor
Jun 29, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move the function Run() back into fd.go.
R=iant CC=golang-dev, rsc
https://golang.org/cl/1748041
parent
da69685e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
46 deletions
+44
-46
fd.go
src/pkg/net/fd.go
+44
-0
newpollserver.go
src/pkg/net/newpollserver.go
+0
-46
No files found.
src/pkg/net/fd.go
View file @
00ad47f9
...
...
@@ -194,6 +194,50 @@ func (s *pollServer) CheckDeadlines() {
s
.
deadline
=
next_deadline
}
func
(
s
*
pollServer
)
Run
()
{
var
scratch
[
100
]
byte
for
{
var
t
=
s
.
deadline
if
t
>
0
{
t
=
t
-
s
.
Now
()
if
t
<=
0
{
s
.
CheckDeadlines
()
continue
}
}
fd
,
mode
,
err
:=
s
.
poll
.
WaitFD
(
t
)
if
err
!=
nil
{
print
(
"pollServer WaitFD: "
,
err
.
String
(),
"
\n
"
)
return
}
if
fd
<
0
{
// Timeout happened.
s
.
CheckDeadlines
()
continue
}
if
fd
==
s
.
pr
.
Fd
()
{
// Drain our wakeup pipe.
for
nn
,
_
:=
s
.
pr
.
Read
(
scratch
[
0
:
]);
nn
>
0
;
{
nn
,
_
=
s
.
pr
.
Read
(
scratch
[
0
:
])
}
// Read from channels
for
fd
,
ok
:=
<-
s
.
cr
;
ok
;
fd
,
ok
=
<-
s
.
cr
{
s
.
AddFD
(
fd
,
'r'
)
}
for
fd
,
ok
:=
<-
s
.
cw
;
ok
;
fd
,
ok
=
<-
s
.
cw
{
s
.
AddFD
(
fd
,
'w'
)
}
}
else
{
netfd
:=
s
.
LookupFD
(
fd
,
mode
)
if
netfd
==
nil
{
print
(
"pollServer: unexpected wakeup for fd="
,
netfd
,
" mode="
,
string
(
mode
),
"
\n
"
)
continue
}
s
.
WakeFD
(
netfd
,
mode
)
}
}
}
var
wakeupbuf
[
1
]
byte
func
(
s
*
pollServer
)
Wakeup
()
{
s
.
pw
.
Write
(
wakeupbuf
[
0
:
])
}
...
...
src/pkg/net/newpollserver.go
View file @
00ad47f9
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// TODO(rsc): All the prints in this file should go to standard error.
package
net
import
(
...
...
@@ -41,47 +39,3 @@ func newPollServer() (s *pollServer, err os.Error) {
go
s
.
Run
()
return
s
,
nil
}
func
(
s
*
pollServer
)
Run
()
{
var
scratch
[
100
]
byte
for
{
var
t
=
s
.
deadline
if
t
>
0
{
t
=
t
-
s
.
Now
()
if
t
<=
0
{
s
.
CheckDeadlines
()
continue
}
}
fd
,
mode
,
err
:=
s
.
poll
.
WaitFD
(
t
)
if
err
!=
nil
{
print
(
"pollServer WaitFD: "
,
err
.
String
(),
"
\n
"
)
return
}
if
fd
<
0
{
// Timeout happened.
s
.
CheckDeadlines
()
continue
}
if
fd
==
s
.
pr
.
Fd
()
{
// Drain our wakeup pipe.
for
nn
,
_
:=
s
.
pr
.
Read
(
scratch
[
0
:
]);
nn
>
0
;
{
nn
,
_
=
s
.
pr
.
Read
(
scratch
[
0
:
])
}
// Read from channels
for
fd
,
ok
:=
<-
s
.
cr
;
ok
;
fd
,
ok
=
<-
s
.
cr
{
s
.
AddFD
(
fd
,
'r'
)
}
for
fd
,
ok
:=
<-
s
.
cw
;
ok
;
fd
,
ok
=
<-
s
.
cw
{
s
.
AddFD
(
fd
,
'w'
)
}
}
else
{
netfd
:=
s
.
LookupFD
(
fd
,
mode
)
if
netfd
==
nil
{
print
(
"pollServer: unexpected wakeup for fd="
,
netfd
,
" mode="
,
string
(
mode
),
"
\n
"
)
continue
}
s
.
WakeFD
(
netfd
,
mode
)
}
}
}
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