Base class holding the lock byte and the bit‐packing helpers shared by every MicroLock specialization.

Synopsis

Declared in <folly/MicroLock.h>

class MicroLockCore;

Member Functions

Name

Description

load

Loads the data stored in the unused bits of the lock atomically.

store

Stores the data in the unused bits of the lock atomically. Since 2 bits are used by the lock, the most significant 2 bits of the provided value will be ignored.

unlock

Release the lock without modifying the stored data bits.

unlockAndStore

Unlocks the lock and stores the bits of the provided value into the data bits. Since 2 bits are used by the lock, the most significant 2 bits of the provided value will be ignored.

Protected Member Functions

Name

Description

heldBit

Mask for bit indicating that the flag is held.

lockSlowPath

Acquire the lock along the contended path, spinning then yielding.

unlockAndStoreWithModifier

Unlock the lock, applying a modifier to compute the stored word.

waitBit

Mask for bit indicating that there is a waiter that should be woken up.

Protected Static Member Functions

Name

Description

decodeDataFromByte

Decodes the value stored in the unused bits of the lock.

decodeDataFromWord

Decode the user data stored in the data bits of a lock word.

encodeDataToByte

Encodes the value for the unused bits of the lock.

encodeDataToWord

Encode user data into the data bits of a lock word, preserving lock bits.

Protected Data Members

Name

Description

lock_

The single byte holding both the lock bits and the packed data bits.

Protected Static Data Members

Name

Description

kDataBits

Mask selecting the bits available for user data.

kLockBits

Mask selecting the bits reserved for lock state.

kNumLockBits

Number of low bits reserved for lock state.

Derived Classes

Name

Description

MicroLockBase

A tiny one‐byte spinlock with a configurable spin and yield budget.

Created with MrDocs