-
Notifications
You must be signed in to change notification settings - Fork 0
/
opset.go
34 lines (29 loc) · 877 Bytes
/
opset.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package inflight
// OpSet represents the set of Ops that have been merged in an OpQueue,
// It provides convenience functions for appending new Ops and for completing them.
type OpSet struct {
set []*Op
}
func newOpSet(op *Op) *OpSet {
return &OpSet{
set: []*Op{op},
}
}
func (os *OpSet) append(op *Op) {
os.set = append(os.set, op)
}
// Ops get the list of ops in this set.
func (os *OpSet) Ops() []*Op {
return os.set
}
// FinishAll a convenience func that calls finish on each Op in the set, passing the
// results or error to all the Ops in the OpSet.
//
// NOTE: The call group that owns this OP will not call it's finish function until all
// Ops are complete. And one callgroup could be spread over multiple op sets or
// multiple op queues.
func (os *OpSet) FinishAll(err error, resp interface{}) {
for _, op := range os.set {
op.Finish(err, resp)
}
}