mirror of https://github.com/grpc/grpc-go.git
transport: replace isItem with a marker method
Also changes the receivers to pointers because: - Implementing an interface using value receivers causes both pointers and values to implement that interface; implementing an interface using pointer receivers causes only pointers to implement the interface, thereby providing better type safety. - Wrapping any value other than an empty struct in an interface causes the value to be heap-allocated; no additional allocations are therefore caused by this change.
This commit is contained in:
parent
5aeebcd810
commit
036dca28a6
|
|
@ -56,43 +56,33 @@ type windowUpdate struct {
|
||||||
increment uint32
|
increment uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
func (windowUpdate) isItem() bool {
|
func (*windowUpdate) item() {}
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
type settings struct {
|
type settings struct {
|
||||||
ack bool
|
ack bool
|
||||||
ss []http2.Setting
|
ss []http2.Setting
|
||||||
}
|
}
|
||||||
|
|
||||||
func (settings) isItem() bool {
|
func (*settings) item() {}
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
type resetStream struct {
|
type resetStream struct {
|
||||||
streamID uint32
|
streamID uint32
|
||||||
code http2.ErrCode
|
code http2.ErrCode
|
||||||
}
|
}
|
||||||
|
|
||||||
func (resetStream) isItem() bool {
|
func (*resetStream) item() {}
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
type flushIO struct {
|
type flushIO struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (flushIO) isItem() bool {
|
func (*flushIO) item() {}
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
type ping struct {
|
type ping struct {
|
||||||
ack bool
|
ack bool
|
||||||
data [8]byte
|
data [8]byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ping) isItem() bool {
|
func (*ping) item() {}
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
// quotaPool is a pool which accumulates the quota and sends it to acquire()
|
// quotaPool is a pool which accumulates the quota and sends it to acquire()
|
||||||
// when it is available.
|
// when it is available.
|
||||||
|
|
|
||||||
|
|
@ -63,13 +63,11 @@ type recvMsg struct {
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (recvMsg) isItem() bool {
|
func (*recvMsg) item() {}
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
// All items in an out of a recvBuffer should be the same type.
|
// All items in an out of a recvBuffer should be the same type.
|
||||||
type item interface {
|
type item interface {
|
||||||
isItem() bool
|
item()
|
||||||
}
|
}
|
||||||
|
|
||||||
// recvBuffer is an unbounded channel of item.
|
// recvBuffer is an unbounded channel of item.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue