Skip to content

Commit

Permalink
make Receive usage stricter, and document
Browse files Browse the repository at this point in the history
  • Loading branch information
jrick committed May 15, 2024
1 parent a8a153d commit 041c47a
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions mixing/mixpool/mixpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -651,8 +651,9 @@ PRLoop:
}

// Received is a parameter for Pool.Receive describing the session and run to
// receive messages for, and slices for returning results. Only non-nil slices
// will be appended to. Received messages are unsorted.
// receive messages for, and slices for returning results. A single non-nil
// slices is required and indicates which message slice will be will be
// appended to. Received messages are unsorted.
type Received struct {
Sid [32]byte
Run uint32
Expand Down Expand Up @@ -696,6 +697,32 @@ func (p *Pool) Receive(ctx context.Context, expectedMessages int, r *Received) e
}
rs = &ses.runs[run]

nonNilSlices := 0
if r.KEs != nil {
nonNilSlices++
}
if r.CTs != nil {
nonNilSlices++
}
if r.SRs != nil {
nonNilSlices++
}
if r.DCs != nil {
nonNilSlices++
}
if r.CMs != nil {
nonNilSlices++
}
if r.FPs != nil {
nonNilSlices++
}
if r.RSs != nil {
nonNilSlices++
}
if nonNilSlices != 1 {
return fmt.Errorf("mixpool: exactly one Received slice must be non-nil")
}

Loop:
for {
// Pool is locked for reads. Count if the total number of
Expand Down

0 comments on commit 041c47a

Please sign in to comment.