fasthttp: github.com/valyala/fasthttp/stackless Index | Files

package stackless

import "github.com/valyala/fasthttp/stackless"

Package stackless provides functionality that may save stack space for high number of concurrently running goroutines.

Index

Package Files

doc.go func.go writer.go

func NewFunc Uses

func NewFunc(f func(ctx interface{})) func(ctx interface{}) bool

NewFunc returns stackless wrapper for the function f.

Unlike f, the returned stackless wrapper doesn't use stack space on the goroutine that calls it. The wrapper may save a lot of stack space if the following conditions are met:

- f doesn't contain blocking calls on network, I/O or channels;
- f uses a lot of stack space;
- the wrapper is called from high number of concurrent goroutines.

The stackless wrapper returns false if the call cannot be processed at the moment due to high load.

type NewWriterFunc Uses

type NewWriterFunc func(w io.Writer) Writer

NewWriterFunc must return new writer that will be wrapped into stackless writer.

type Writer Uses

type Writer interface {
    Write(p []byte) (int, error)
    Flush() error
    Close() error
    Reset(w io.Writer)
}

Writer is an interface stackless writer must conform to.

The interface contains common subset for Writers from compress/* packages.

func NewWriter Uses

func NewWriter(dstW io.Writer, newWriter NewWriterFunc) Writer

NewWriter creates a stackless writer around a writer returned from newWriter.

The returned writer writes data to dstW.

Writers that use a lot of stack space may be wrapped into stackless writer, thus saving stack space for high number of concurrently running goroutines.

Package stackless imports 6 packages (graph) and is imported by 25 packages. Updated 2018-08-20. Refresh now. Tools for package owners.