github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/internal/poll/fd.go (about)

     1  // Copyright 2017 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Package poll supports non-blocking I/O on file descriptors with polling.
     6  // This supports I/O operations that block only a goroutine, not a thread.
     7  // This is used by the net and os packages.
     8  // It uses a poller built into the runtime, with support from the
     9  // runtime scheduler.
    10  package poll
    11  
    12  import (
    13  	"github.com/shogo82148/std/errors"
    14  )
    15  
    16  // ErrNetClosing is returned when a network descriptor is used after
    17  // it has been closed.
    18  var ErrNetClosing = errNetClosing{}
    19  
    20  // ErrFileClosing is returned when a file descriptor is used after it
    21  // has been closed.
    22  var ErrFileClosing = errors.New("use of closed file")
    23  
    24  // ErrNoDeadline is returned when a request is made to set a deadline
    25  // on a file type that does not use the poller.
    26  var ErrNoDeadline = errors.New("file type does not support deadline")
    27  
    28  // ErrDeadlineExceeded is returned for an expired deadline.
    29  // This is exported by the os package as os.ErrDeadlineExceeded.
    30  var ErrDeadlineExceeded error = &DeadlineExceededError{}
    31  
    32  // DeadlineExceededError is returned for an expired deadline.
    33  type DeadlineExceededError struct{}
    34  
    35  // Implement the net.Error interface.
    36  // The string is "i/o timeout" because that is what was returned
    37  // by earlier Go versions. Changing it may break programs that
    38  // match on error strings.
    39  func (e *DeadlineExceededError) Error() string
    40  func (e *DeadlineExceededError) Timeout() bool
    41  func (e *DeadlineExceededError) Temporary() bool
    42  
    43  // ErrNotPollable is returned when the file or socket is not suitable
    44  // for event notification.
    45  var ErrNotPollable = errors.New("not pollable")
    46  
    47  // TestHookDidWritev is a hook for testing writev.
    48  var TestHookDidWritev = func(wrote int) {}
    49  
    50  // String is an internal string definition for methods/functions
    51  // that is not intended for use outside the standard libraries.
    52  //
    53  // Other packages in std that import internal/poll and have some
    54  // exported APIs (now we've got some in net.rawConn) which are only used
    55  // internally and are not intended to be used outside the standard libraries,
    56  // Therefore, we make those APIs use internal types like poll.FD or poll.String
    57  // in their function signatures to disable the usability of these APIs from
    58  // external codebase.
    59  type String string