Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update state by one bit #264

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,19 @@ const (
// State enumerates possible slot states.
type State byte

// State values are intentionally chosen in a way where following states differ by one bit only.
// It is designed this way to guarantee that goroutines read (maybe outdated but) valid state values.
// This hack is probably not needed because x86 CPUs guarantee write consistency on DWORD level,
// but this business is crazy and nothing is going to surprise me.
const (
// StateFree means slot is free.
StateFree State = iota
StateFree State = 0

// StateData means slot contains data.
StateData
StateData State = 1

// StatePointer means slot contains pointer.
StatePointer
StatePointer State = 3
)

// Flags defines pointer flags.
Expand Down
Loading