MCPcopy
hub / github.com/SurgeDM/Surge / setChunkState

Method setChunkState

internal/engine/types/progress.go:392–408  ·  view source on GitHub ↗

setChunkState sets the 2-bit state (internal, expects lock)

(index int, status ChunkStatus)

Source from the content-addressed store, hash-verified

390
391// setChunkState sets the 2-bit state (internal, expects lock)
392func (ps *ProgressState) setChunkState(index int, status ChunkStatus) {
393 if index < 0 || index >= ps.BitmapWidth {
394 return
395 }
396
397 byteIndex := index / 4
398 if byteIndex >= len(ps.ChunkBitmap) {
399 return
400 }
401 bitOffset := (index % 4) * 2
402
403 mask := byte(3 << bitOffset)
404 ps.ChunkBitmap[byteIndex] &= ^mask
405
406 val := byte(status) << bitOffset
407 ps.ChunkBitmap[byteIndex] |= val
408}
409
410// GetChunkState gets the 2-bit state for a specific chunk index (thread-safe)
411func (ps *ProgressState) GetChunkState(index int) ChunkStatus {

Callers 3

SetChunkStateMethod · 0.95
UpdateChunkStatusMethod · 0.95
RecalculateProgressMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected