Version: v3.1.0-fork Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2020 License: Apache-2.0 Imports: 2 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


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 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.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL