1package gocbcore
2
3import "sync/atomic"
4
5// PendingOp represents an outstanding operation within the client.
6// This can be used to cancel an operation before it completes.
7// This can also be used to Get information about the operation once
8// it has completed (cancelled or successful).
9type PendingOp interface {
10	Cancel()
11}
12
13type multiPendingOp struct {
14	ops          []PendingOp
15	completedOps uint32
16	isIdempotent bool
17}
18
19func (mp *multiPendingOp) Cancel() {
20	for _, op := range mp.ops {
21		op.Cancel()
22	}
23}
24
25func (mp *multiPendingOp) CompletedOps() uint32 {
26	return atomic.LoadUint32(&mp.completedOps)
27}
28
29func (mp *multiPendingOp) IncrementCompletedOps() uint32 {
30	return atomic.AddUint32(&mp.completedOps, 1)
31}
32