// 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")
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')
}
// 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()
}
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)
}
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')
}
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)
}
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')
}
}
}
-// 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 {
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()
+}
package poll
-import (
- "syscall"
-)
+import "syscall"
// CloseFunc is used to hook the close call.
var CloseFunc func(int) error = syscall.Close
package poll
-import (
- "syscall"
-)
+import "syscall"
// CloseFunc is used to hook the close call.
var CloseFunc func(syscall.Handle) error = syscall.Closesocket
package poll
-import (
- "syscall"
-)
+import "syscall"
// Wrapper around the accept system call that marks the returned file
// descriptor as nonblocking and close-on-exec.
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 {
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 {
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 {
-// +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