-
Notifications
You must be signed in to change notification settings - Fork 17.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net: refactor poller into new internal/poll package
This will make it possible to use the poller with the os package. This is a lot of code movement but the behavior is intended to be unchanged. Update #6817. Update #7903. Update #15021. Update #18507. Change-Id: I1413685928017c32df5654ded73a2643820977ae Reviewed-on: https://go-review.googlesource.com/36799 Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: David Crawshaw <[email protected]> Reviewed-by: Russ Cox <[email protected]>
- Loading branch information
1 parent
b548eee
commit 3792db5
Showing
79 changed files
with
2,722 additions
and
1,619 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2010 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. | ||
|
||
// Export guts for testing. | ||
// Since testing imports os and os imports internal/poll, | ||
// the internal/poll tests can not be in package poll. | ||
|
||
package poll | ||
|
||
var Consume = consume | ||
|
||
type FDMutex struct { | ||
fdMutex | ||
} | ||
|
||
func (mu *FDMutex) Incref() bool { | ||
return mu.incref() | ||
} | ||
|
||
func (mu *FDMutex) IncrefAndClose() bool { | ||
return mu.increfAndClose() | ||
} | ||
|
||
func (mu *FDMutex) Decref() bool { | ||
return mu.decref() | ||
} | ||
|
||
func (mu *FDMutex) RWLock(read bool) bool { | ||
return mu.rwlock(read) | ||
} | ||
|
||
func (mu *FDMutex) RWUnlock(read bool) bool { | ||
return mu.rwunlock(read) | ||
} | ||
|
||
func (fd *FD) EOFError(n int, err error) error { | ||
return fd.eofError(n, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2017 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. | ||
|
||
// Package poll supports non-blocking I/O on file descriptors with polling. | ||
// This supports I/O operations that block only a goroutine, not a thread. | ||
// This is used by the net and os packages. | ||
// It uses a poller built into the runtime, with support from the | ||
// runtime scheduler. | ||
package poll | ||
|
||
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") | ||
|
||
// ErrTimeout is returned for an expired deadline. | ||
var ErrTimeout error = &TimeoutError{} | ||
|
||
// TimeoutError is returned for an expired deadline. | ||
type TimeoutError struct{} | ||
|
||
// Implement the net.Error interface. | ||
func (e *TimeoutError) Error() string { return "i/o timeout" } | ||
func (e *TimeoutError) Timeout() bool { return true } | ||
func (e *TimeoutError) Temporary() bool { return true } | ||
|
||
// consume removes data from a slice of byte slices, for writev. | ||
func consume(v *[][]byte, n int64) { | ||
for len(*v) > 0 { | ||
ln0 := int64(len((*v)[0])) | ||
if ln0 > n { | ||
(*v)[0] = (*v)[0][n:] | ||
return | ||
} | ||
n -= ln0 | ||
*v = (*v)[1:] | ||
} | ||
} | ||
|
||
// TestHookDidWritev is a hook for testing writev. | ||
var TestHookDidWritev = func(wrote int) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.