• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

README.mdH A D14-Jul-20212.3 KiB11985

chan.goH A D14-Jul-20211.9 KiB9661

doc.goH A D14-Jul-2021159 61

signal.goH A D14-Jul-20212.6 KiB10971

README.md

1# package drpcsignal
2
3`import "storj.io/drpc/drpcsignal"`
4
5Package drpcsignal holds a helper type to signal errors.
6
7## Usage
8
9#### type Chan
10
11```go
12type Chan struct {
13}
14```
15
16Chan is a lazily allocated chan struct{} that avoids allocating if it is closed
17before being used for anything.
18
19#### func (*Chan) Close
20
21```go
22func (c *Chan) Close()
23```
24Close tries to set the channel to an already closed one if a fresh one has not
25already been set, and closes the fresh one otherwise.
26
27#### func (*Chan) Full
28
29```go
30func (c *Chan) Full() bool
31```
32Full returns true if the channel is currently full. The information is
33immediately invalid in the sense that a send could always block.
34
35#### func (*Chan) Get
36
37```go
38func (c *Chan) Get() chan struct{}
39```
40Get returns the channel, allocating if necessary.
41
42#### func (*Chan) Make
43
44```go
45func (c *Chan) Make(cap uint)
46```
47Make sets the channel to a freshly allocated channel with the provided capacity.
48It is a no-op if called after any other methods.
49
50#### func (*Chan) Recv
51
52```go
53func (c *Chan) Recv()
54```
55Recv receives a value on the channel, allocating if necessary.
56
57#### func (*Chan) Send
58
59```go
60func (c *Chan) Send()
61```
62Send sends a value on the channel, allocating if necessary.
63
64#### type Signal
65
66```go
67type Signal struct {
68}
69```
70
71Signal contains an error value that can be set one and exports a number of ways
72to inspect it.
73
74#### func (*Signal) Err
75
76```go
77func (s *Signal) Err() error
78```
79Err returns the error stored in the signal. Since one can store a nil error care
80must be taken. A non-nil error returned from this method means that the Signal
81has been set, but the inverse is not true.
82
83#### func (*Signal) Get
84
85```go
86func (s *Signal) Get() (error, bool)
87```
88Get returns the error set with the signal and a boolean indicating if the result
89is valid.
90
91#### func (*Signal) IsSet
92
93```go
94func (s *Signal) IsSet() bool
95```
96IsSet returns true if the Signal is set.
97
98#### func (*Signal) Set
99
100```go
101func (s *Signal) Set(err error) (ok bool)
102```
103Set stores the error in the signal. It only keeps track of the first error set,
104and returns true if it was the first error set.
105
106#### func (*Signal) Signal
107
108```go
109func (s *Signal) Signal() chan struct{}
110```
111Signal returns a channel that will be closed when the signal is set.
112
113#### func (*Signal) Wait
114
115```go
116func (s *Signal) Wait()
117```
118Wait blocks until the signal has been Set.
119