drpcsignal

package
v0.0.33 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: MIT Imports: 2 Imported by: 0

README

package drpcsignal

import "storj.io/drpc/drpcsignal"

Package drpcsignal holds a helper type to signal errors.

Usage

type Chan
type Chan struct {
}

Chan is a lazily allocated chan struct{} that avoids allocating if it is closed before being used for anything.

func (*Chan) Close
func (c *Chan) Close()

Close tries to set the channel to an already closed one if a fresh one has not already been set, and closes the fresh one otherwise.

func (*Chan) Full
func (c *Chan) Full() bool

Full returns true if the channel is currently full. The information is immediately invalid in the sense that a send could always block.

func (*Chan) Get
func (c *Chan) Get() chan struct{}

Get returns the channel, allocating if necessary.

func (*Chan) Make
func (c *Chan) Make(cap uint)

Make sets the channel to a freshly allocated channel with the provided capacity. It is a no-op if called after any other methods.

func (*Chan) Recv
func (c *Chan) Recv()

Recv receives a value on the channel, allocating if necessary.

func (*Chan) Send
func (c *Chan) Send()

Send sends a value on the channel, allocating if necessary.

type Signal
type Signal struct {
}

Signal contains an error value that can be set one and exports a number of ways to inspect it.

func (*Signal) Err
func (s *Signal) Err() error

Err returns the error stored in the signal. Since one can store a nil error care must be taken. A non-nil error returned from this method means that the Signal has been set, but the inverse is not true.

func (*Signal) Get
func (s *Signal) Get() (error, bool)

Get returns the error set with the signal and a boolean indicating if the result is valid.

func (*Signal) IsSet
func (s *Signal) IsSet() bool

IsSet returns true if the Signal is set.

func (*Signal) Set
func (s *Signal) Set(err error) (ok bool)

Set stores the error in the signal. It only keeps track of the first error set, and returns true if it was the first error set.

func (*Signal) Signal
func (s *Signal) Signal() chan struct{}

Signal returns a channel that will be closed when the signal is set.

func (*Signal) Wait
func (s *Signal) Wait()

Wait blocks until the signal has been Set.

Documentation

Overview

Package drpcsignal holds a helper type to signal errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chan added in v0.0.22

type Chan struct {
	// contains filtered or unexported fields
}

Chan is a lazily allocated chan struct{} that avoids allocating if it is closed before being used for anything.

func (*Chan) Close added in v0.0.22

func (c *Chan) Close()

Close tries to set the channel to an already closed one if a fresh one has not already been set, and closes the fresh one otherwise.

func (*Chan) Full added in v0.0.22

func (c *Chan) Full() bool

Full returns true if the channel is currently full. The information is immediately invalid in the sense that a send could always block.

func (*Chan) Get added in v0.0.22

func (c *Chan) Get() chan struct{}

Get returns the channel, allocating if necessary.

func (*Chan) Make added in v0.0.22

func (c *Chan) Make(cap uint)

Make sets the channel to a freshly allocated channel with the provided capacity. It is a no-op if called after any other methods.

func (*Chan) Recv added in v0.0.22

func (c *Chan) Recv()

Recv receives a value on the channel, allocating if necessary.

func (*Chan) Send added in v0.0.22

func (c *Chan) Send()

Send sends a value on the channel, allocating if necessary.

type Signal

type Signal struct {
	// contains filtered or unexported fields
}

Signal contains an error value that can be set one and exports a number of ways to inspect it.

func (*Signal) Err

func (s *Signal) Err() error

Err returns the error stored in the signal. Since one can store a nil error care must be taken. A non-nil error returned from this method means that the Signal has been set, but the inverse is not true.

func (*Signal) Get

func (s *Signal) Get() (error, bool)

Get returns the error set with the signal and a boolean indicating if the result is valid.

func (*Signal) IsSet

func (s *Signal) IsSet() bool

IsSet returns true if the Signal is set.

func (*Signal) Set

func (s *Signal) Set(err error) (ok bool)

Set stores the error in the signal. It only keeps track of the first error set, and returns true if it was the first error set.

func (*Signal) Signal

func (s *Signal) Signal() chan struct{}

Signal returns a channel that will be closed when the signal is set.

func (*Signal) Wait added in v0.0.22

func (s *Signal) Wait()

Wait blocks until the signal has been Set.

Jump to

Keyboard shortcuts

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