Documentation
¶
Overview ¶
Package readcontrol shares input-consumer ownership between the transport and the protocol packages without exposing owner handles in the public API.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrUnsupported = errors.New("unsupported method")
ErrUnsupported is shared with uio.ErrUnsupported without an import cycle.
Functions ¶
This section is empty.
Types ¶
type Access ¶
type Access[T Getter] struct{}
Access exposes only a package-private capability. Embedding this zero-sized value first in a connection preserves its layout and lets sibling packages acquire their own pause owner without adding public factory methods. The original source is passed through, so a getter can support promoted access from wrappers by asserting a private provider interface in its own package.
type Control ¶
type Control struct {
// contains filtered or unexported fields
}
Control counts the reasons one input boundary is paused. While any owner holds a pause the boundary's consumer callback does not run; the boundary keeps its input and decides for itself what else stops (a plain socket stops reading it, a layer stack keeps reading up to its bounds).
Besides the count it keeps one fact for the boundary: a release whose resume turn has not reached the consumer yet (see Held). The end of the stream waits for that turn as it waits for a pause, so the consumer sees what it retained, and the end, before the connection closes. Neither stops a producer: what else a pause stops, what is retained and when the end may complete are the boundary's. The zero value is usable; New attaches the hooks. It must not be copied after its first use.
func ControlOf ¶
ControlOf resolves an existing boundary's shared control. A custom Conn without the private capability returns nil; callers must not substitute the application's public pause slot for independently owned internal pauses.
func New ¶
New constructs a controller for an input boundary. check validates a new pause against the boundary's lifecycle; resume asks for a turn that hands retained input to the consumer once the last pause is released. Either may be nil. Both must be concurrency safe and return promptly, and resume must schedule work rather than run the consumer inline. Neither runs under an owner's lock.
func (*Control) ConsumerRuns ¶
func (c *Control) ConsumerRuns()
ConsumerRuns records the consumer's callback starting unpaused, clearing any owed resume turn.
func (*Control) Held ¶
Held reports whether the end of the stream must wait for the consumer: a pause holds it, or a released pause's resume turn has not run yet.
func (*Control) NewPause ¶
NewPause creates an independent owner of this control, initially unpaused.
func (*Control) PauseRead ¶
PauseRead and ResumeRead operate the application's own owner. It is one switch, idempotent rather than reference counted.
func (*Control) ReadPaused ¶
ReadPaused reports whether any owner holds a pause.
func (*Control) ResumeRead ¶
type Getter ¶
Getter locates the control belonging to the original dynamic input boundary. Implement it on a private zero-sized type in the boundary's owning package. The zero value must be usable and must not create a second control for the same input boundary.
type Pause ¶
type Pause struct {
// contains filtered or unexported fields
}
Pause owns one reason to pause an input boundary. Pause is idempotent for its owner and Resume releases only its own pause, never another owner's. Do not copy it.
func NewPause ¶
NewPause acquires an initially unpaused owner of source's input boundary. Unsupported sources return nil; nil handles report ErrUnsupported.
func (*Pause) Resume ¶
Resume releases this owner's pause; the last release asks the boundary for a turn that hands its retained input to the consumer. An owner that holds no pause changes nothing and schedules nothing: a callback that left input unconsumed without pausing asks for its next turn with Wake instead.