]> Cypherpunks repositories - gostls13.git/commitdiff
internal/poll: code cleanup
authorMikio Hara <mikioh.mikioh@gmail.com>
Mon, 6 Mar 2017 09:39:02 +0000 (18:39 +0900)
committerMikio Hara <mikioh.mikioh@gmail.com>
Tue, 7 Mar 2017 21:54:36 +0000 (21:54 +0000)
This change adds missing docs, collapses single-line import paths,
removes unsed method placeholders and renames str.go to strconv.go.

Change-Id: I2d155c838935cd8427abd142a462ff4c56829703
Reviewed-on: https://go-review.googlesource.com/37814
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
12 files changed:
src/internal/poll/fd.go
src/internal/poll/fd_plan9.go
src/internal/poll/fd_poll_nacl.go
src/internal/poll/fd_poll_runtime.go
src/internal/poll/fd_unix.go
src/internal/poll/hook_unix.go
src/internal/poll/hook_windows.go
src/internal/poll/sock_cloexec.go
src/internal/poll/sockopt.go
src/internal/poll/sockopt_linux.go
src/internal/poll/sockopt_windows.go
src/internal/poll/strconv.go [moved from src/internal/poll/str.go with 100% similarity]

index 0752876be2db2016de7f9f96b2344fe82c35a279..3d3f36edb3ba71b05c771876a76881e2ebad21d5 100644 (file)
@@ -9,9 +9,7 @@
 // runtime scheduler.
 package poll
 
-import (
-       "errors"
-)
+import "errors"
 
 // ErrClosing is returned when a descriptor is used after it has been closed.
 var ErrClosing = errors.New("use of closed file or network connection")
index 5b2c674b36db20bf72b29c955fed34bdff6fc359..a8c4b1c201314f6312c6294e46f35f2d7b6ab19f 100644 (file)
@@ -90,14 +90,17 @@ func (fd *FD) Write(fn func([]byte) (int, error), b []byte) (int, error) {
        return n, err
 }
 
+// SetDeadline sets the read and write deadlines associated with fd.
 func (fd *FD) SetDeadline(t time.Time) error {
        return setDeadlineImpl(fd, t, 'r'+'w')
 }
 
+// SetReadDeadline sets the read deadline associated with fd.
 func (fd *FD) SetReadDeadline(t time.Time) error {
        return setDeadlineImpl(fd, t, 'r')
 }
 
+// SetWriteDeadline sets the write deadline associated with fd.
 func (fd *FD) SetWriteDeadline(t time.Time) error {
        return setDeadlineImpl(fd, t, 'w')
 }
@@ -163,10 +166,12 @@ func setDeadlineImpl(fd *FD, t time.Time, mode int) error {
 
 // On Plan 9 only, expose the locking for the net code.
 
+// ReadLock wraps FD.readLock.
 func (fd *FD) ReadLock() error {
        return fd.readLock()
 }
 
+// ReadUnlock wraps FD.readUnlock.
 func (fd *FD) ReadUnlock() {
        fd.readUnlock()
 }
@@ -179,6 +184,8 @@ func isInterrupted(err error) bool {
        return err != nil && stringsHasSuffix(err.Error(), "interrupted")
 }
 
+// PollDescriptor returns the descriptor being used by the poller,
+// or ^uintptr(0) if there isn't one. This is only used for testing.
 func PollDescriptor() uintptr {
        return ^uintptr(0)
 }
index 8cf54ef6d50b174447a6958e1ec07f6fc0a116e1..45256a42d33d445b30da80200ab13f0f8c14d243 100644 (file)
@@ -49,18 +49,17 @@ func (pd *pollDesc) waitWrite() error { return pd.wait('w') }
 
 func (pd *pollDesc) waitCanceled(mode int) {}
 
-func (pd *pollDesc) waitCanceledRead() {}
-
-func (pd *pollDesc) waitCanceledWrite() {}
-
+// SetDeadline sets the read and write deadlines associated with fd.
 func (fd *FD) SetDeadline(t time.Time) error {
        return setDeadlineImpl(fd, t, 'r'+'w')
 }
 
+// SetReadDeadline sets the read deadline associated with fd.
 func (fd *FD) SetReadDeadline(t time.Time) error {
        return setDeadlineImpl(fd, t, 'r')
 }
 
+// SetWriteDeadline sets the write deadline associated with fd.
 func (fd *FD) SetWriteDeadline(t time.Time) error {
        return setDeadlineImpl(fd, t, 'w')
 }
@@ -86,6 +85,8 @@ func setDeadlineImpl(fd *FD, t time.Time, mode int) error {
        return nil
 }
 
+// PollDescriptor returns the descriptor being used by the poller,
+// or ^uintptr(0) if there isn't one. This is only used for testing.
 func PollDescriptor() uintptr {
        return ^uintptr(0)
 }
index 032a0f71bbed1096c496cc5cac0bdc387199106a..b1e3a84fc2b900416be201dfa726efc7051a7707 100644 (file)
@@ -114,14 +114,17 @@ func convertErr(res int) error {
        panic("unreachable")
 }
 
+// SetDeadline sets the read and write deadlines associated with fd.
 func (fd *FD) SetDeadline(t time.Time) error {
        return setDeadlineImpl(fd, t, 'r'+'w')
 }
 
+// SetReadDeadline sets the read deadline associated with fd.
 func (fd *FD) SetReadDeadline(t time.Time) error {
        return setDeadlineImpl(fd, t, 'r')
 }
 
+// SetWriteDeadline sets the write deadline associated with fd.
 func (fd *FD) SetWriteDeadline(t time.Time) error {
        return setDeadlineImpl(fd, t, 'w')
 }
index 0cf3d933aa9d16a73756997a22b4da9126b84979..8aaec14cc45b0e533db1bc90bc9c4f2b56d564fd 100644 (file)
@@ -313,11 +313,6 @@ func (fd *FD) WriteMsg(p []byte, oob []byte, sa syscall.Sockaddr) (int, int, err
        }
 }
 
-// WaitWrite waits until data can be written to fd.
-func (fd *FD) WaitWrite() error {
-       return fd.pd.waitWrite()
-}
-
 // Accept wraps the accept network call.
 func (fd *FD) Accept() (int, syscall.Sockaddr, string, error) {
        if err := fd.readLock(); err != nil {
@@ -397,3 +392,10 @@ func (fd *FD) Fstat(s *syscall.Stat_t) error {
        defer fd.decref()
        return syscall.Fstat(fd.Sysfd, s)
 }
+
+// On Unix variants only, expose the IO event for the net code.
+
+// WaitWrite waits until data can be read from fd.
+func (fd *FD) WaitWrite() error {
+       return fd.pd.waitWrite()
+}
index 4a6ff6cd49e1bd28f182ec9079502bee9e0c0e16..85e102dd73e0fec10b252af3625b39ec82d933d5 100644 (file)
@@ -6,9 +6,7 @@
 
 package poll
 
-import (
-       "syscall"
-)
+import "syscall"
 
 // CloseFunc is used to hook the close call.
 var CloseFunc func(int) error = syscall.Close
index 97665554e8c1a8e792921abad6dec0d534e21b24..0bd950ebe46d7f5f823333bc155dbe89d469096a 100644 (file)
@@ -4,9 +4,7 @@
 
 package poll
 
-import (
-       "syscall"
-)
+import "syscall"
 
 // CloseFunc is used to hook the close call.
 var CloseFunc func(syscall.Handle) error = syscall.Closesocket
index 28b950c33043b5bddcdd31a16bbc217cb788186f..705f2c8f795ce8435a2a20a30ac153ca87bc200f 100644 (file)
@@ -9,9 +9,7 @@
 
 package poll
 
-import (
-       "syscall"
-)
+import "syscall"
 
 // Wrapper around the accept system call that marks the returned file
 // descriptor as nonblocking and close-on-exec.
index b841699a9cba2f73b2f533a01d61c3ff4cb4da82..f86ce707a123aef486af92d3e908344a5ca4ed07 100644 (file)
@@ -6,9 +6,7 @@
 
 package poll
 
-import (
-       "syscall"
-)
+import "syscall"
 
 // SetsockoptInt wraps the setsockopt network call with an int argument.
 func (fd *FD) SetsockoptInt(level, name, arg int) error {
index ba616db8556422d5ea38edc4e7f86ee9df213afa..acd75f68f40a1d023b9de929c220cb64f7fda6e3 100644 (file)
@@ -4,9 +4,7 @@
 
 package poll
 
-import (
-       "syscall"
-)
+import "syscall"
 
 // SetsockoptIPMreqn wraps the setsockopt network call with a IPMreqn argument.
 func (fd *FD) SetsockoptIPMreqn(level, name int, mreq *syscall.IPMreqn) error {
index 70501a0965298064fe34e36eb0b5acb88657abb4..7d63fc362c5126af1fd0b8d64088f536aaf103e7 100644 (file)
@@ -4,9 +4,7 @@
 
 package poll
 
-import (
-       "syscall"
-)
+import "syscall"
 
 // Setsockopt wraps the Windows setsockopt network call.
 func (fd *FD) Setsockopt(level, optname int32, optval *byte, optlen int32) error {
similarity index 100%
rename from src/internal/poll/str.go
rename to src/internal/poll/strconv.go
index 57ec9d9c2147510715e5095ae4e85a9f6319e784..21cb40db70e8aa142797d28edcd890878c1c1cb7 100644 (file)
@@ -1,9 +1,9 @@
-// +build plan9
-
 // Copyright 2009 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// +build plan9
+
 // Simple conversions to avoid depending on strconv.
 
 package poll