Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConcurrentBitmap ¶
type ConcurrentBitmap struct {
// contains filtered or unexported fields
}
ConcurrentBitmap is a static-length bitmap which is thread-safe on setting. It is implemented using CAS, as atomic bitwise operation is not supported by golang yet. (See https://github.com/golang/go/issues/24244) CAS operation is narrowed down to uint32 instead of longer types like uint64, to reduce probability of racing.
func NewConcurrentBitmap ¶
func NewConcurrentBitmap(bitLen int) *ConcurrentBitmap
NewConcurrentBitmap initializes a ConcurrentBitmap which can store bitLen of bits.
func (*ConcurrentBitmap) BytesConsumed ¶
func (cb *ConcurrentBitmap) BytesConsumed() int64
BytesConsumed returns size of this bitmap in bytes.
func (*ConcurrentBitmap) Set ¶
func (cb *ConcurrentBitmap) Set(bitIndex int) (isSetter bool)
Set sets the bit on bitIndex to be 1 (bitIndex starts from 0). isSetter indicates whether the function call this time triggers the bit from 0 to 1. bitIndex bigger than bitLen initialized will be ignored.
func (*ConcurrentBitmap) UnsafeIsSet ¶
func (cb *ConcurrentBitmap) UnsafeIsSet(bitIndex int) (isSet bool)
UnsafeIsSet returns if a bit on bitIndex is set (bitIndex starts from 0). bitIndex bigger than bitLen initialized will return false. This method is not thread-safe as it does not use atomic load.