setChunkState sets the 2-bit state (internal, expects lock)
(index int, status ChunkStatus)
| 390 | |
| 391 | // setChunkState sets the 2-bit state (internal, expects lock) |
| 392 | func (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) |
| 411 | func (ps *ProgressState) GetChunkState(index int) ChunkStatus { |
no outgoing calls
no test coverage detected