Documentation ¶
Overview ¶
Package asyncio provides context-aware alternatives to io methods.
Index ¶
- Variables
- func Copy(ctx context.Context, timeout time.Duration, dst io.Writer, src io.Reader) (written int64, err error)
- func CopyLeak(ctx context.Context, dst io.Writer, src io.Reader) (written int64, err error)
- func Read(ctx context.Context, timeout time.Duration, reader io.Reader, p []byte) (n int, err error)
- func Reader(ctx context.Context, timeout time.Duration, reader io.Reader) io.Reader
- func StdCopy(ctx context.Context, timeout time.Duration, dstout, dsterr io.Writer, ...) (written int64, err error)
- func StdCopyLeak(ctx context.Context, dstout, dsterr io.Writer, src io.Reader) (written int64, err error)
- func Wait(ctx context.Context, timeout time.Duration, action, cancel func()) (ok bool)
- func Write(ctx context.Context, timeout time.Duration, writer io.Writer, p []byte) (n int, err error)
- func Writer(ctx context.Context, timeout time.Duration, writer io.Writer) io.Writer
Constants ¶
This section is empty.
Variables ¶
var ErrCanceled = errors.New("asyncio: Context canceled and timeout expired")
ErrCanceled is returned by Read() or Write() when the context was canceled and the timeout expired.
Functions ¶
func Copy ¶
func Copy(ctx context.Context, timeout time.Duration, dst io.Writer, src io.Reader) (written int64, err error)
Copy is like io.Copy, but wrapping dst and src using Writer and Reader methods.
func CopyLeak ¶
CopyLeak is like Copy with timeout being half the memory leak timeout. It also prints a debug message when the memory leak detector is enabled.
func Read ¶
func Read(ctx context.Context, timeout time.Duration, reader io.Reader, p []byte) (n int, err error)
Read is a replacement for reader.Read() that returns within timeout after context is canncelled.
Read can not cancel the underlying I/O; instead it is left running in a seperate goroutine.
func StdCopy ¶
func StdCopy(ctx context.Context, timeout time.Duration, dstout, dsterr io.Writer, src io.Reader) (written int64, err error)
StdCopy is like stdcopy.StdCopy, but wrapping readers using Reader() and writers using Writer().
func StdCopyLeak ¶
func StdCopyLeak(ctx context.Context, dstout, dsterr io.Writer, src io.Reader) (written int64, err error)
StdCopyLeak is like StdCopy with timeout being half the memory leak timeout.
func Wait ¶
Wait performs action in a concurrent goroutine and returns true once it has completed.
When ctx is canceled, and f is not yet finished, calls cancel. Then waits at most timeout and, if f has not returned, returns false. When cancel is nil, it is not called.
func Write ¶
func Write(ctx context.Context, timeout time.Duration, writer io.Writer, p []byte) (n int, err error)
Write is a replacement for writer.Write() that returns within timeout after context is cancelled.
Write can not cancel the underlying I/O; instead it is left running in a seperate goroutine.
Types ¶
This section is empty.