goprocessctx

package
v0.3.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2015 License: MIT, MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseAfterContext added in v0.3.6

func CloseAfterContext(p goprocess.Process, ctx context.Context)

CloseAfterContext schedules the process to close after the given context is done. It is the equivalent of:

func CloseAfterContext(p goprocess.Process, ctx context.Context) {
  go func() {
    <-ctx.Done()
    p.Close()
  }()
}

func OnClosedContext added in v0.3.8

func OnClosedContext(p goprocess.Process) context.Context

OnClosedContext derives a context from a given goprocess that will be 'Done' when the process is closed

func OnClosingContext added in v0.3.8

func OnClosingContext(p goprocess.Process) context.Context

OnClosingContext derives a context from a given goprocess that will be 'Done' when the process is closing

func WaitForContext

func WaitForContext(ctx context.Context, p goprocess.Process)

WaitForContext makes p WaitFor ctx. When Closing, p waits for ctx.Done(), before being Closed(). It is simply:

p.WaitFor(goprocess.WithContext(ctx))

func WithContext

func WithContext(ctx context.Context) goprocess.Process

WithContext constructs and returns a Process that respects given context. It is the equivalent of:

func ProcessWithContext(ctx context.Context) goprocess.Process {
  p := goprocess.WithParent(goprocess.Background())
  CloseAfterContext(p, ctx)
  return p
}

func WithContextAndTeardown added in v0.3.6

func WithContextAndTeardown(ctx context.Context, tf goprocess.TeardownFunc) goprocess.Process

WithContextAndTeardown is a helper function to set teardown at initiation of WithContext

func WithProcessClosed

func WithProcessClosed(ctx context.Context, p goprocess.Process) context.Context

WithProcessClosed returns a context.Context that is cancelled after Process p is Closed. It is the equivalent of:

func WithProcessClosed(ctx context.Context, p goprocess.Process) context.Context {
  ctx, cancel := context.WithCancel(ctx)
  go func() {
    <-p.Closed()
    cancel()
  }()
  return ctx
}

func WithProcessClosing

func WithProcessClosing(ctx context.Context, p goprocess.Process) context.Context

WithProcessClosing returns a context.Context derived from ctx that is cancelled as p is Closing (after: <-p.Closing()). It is simply:

func WithProcessClosing(ctx context.Context, p goprocess.Process) context.Context {
  ctx, cancel := context.WithCancel(ctx)
  go func() {
    <-p.Closing()
    cancel()
  }()
  return ctx
}

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL