Preconditions: - apfl.canEnqueue() == true. - fr.Length() > 0. - fr must be page-aligned.
(amfl *asyncMemoryFileLoad, fr memmap.FileRange, off uint64, tempRef bool)
| 1481 | // - fr.Length() > 0. |
| 1482 | // - fr must be page-aligned. |
| 1483 | func (apfl *AsyncPagesFileLoad) enqueueRange(amfl *asyncMemoryFileLoad, fr memmap.FileRange, off uint64, tempRef bool) uint64 { |
| 1484 | for { |
| 1485 | if apfl.curOp == nil { |
| 1486 | id, err := apfl.opsBusy.FirstZero(0) |
| 1487 | if err != nil { |
| 1488 | panic(fmt.Sprintf("all ops busy with qavail=%d: %v", apfl.qavail, err)) |
| 1489 | } |
| 1490 | apfl.opsBusy.Add(id) |
| 1491 | op := &apfl.ops[id] |
| 1492 | op.total = 0 |
| 1493 | op.frs = op.frs[:0] |
| 1494 | op.iovecs = op.iovecs[:0] |
| 1495 | apfl.curOp = op |
| 1496 | apfl.curOpID = id |
| 1497 | } |
| 1498 | n := apfl.combine(amfl, fr, off, tempRef) |
| 1499 | if n > 0 { |
| 1500 | return n |
| 1501 | } |
| 1502 | // Flush the existing (conflicting) op and try again with a new one. |
| 1503 | apfl.enqueueCurOp() |
| 1504 | if !apfl.canEnqueue() { |
| 1505 | return 0 |
| 1506 | } |
| 1507 | } |
| 1508 | } |
| 1509 | |
| 1510 | // combine adds as much of the given load as possible to g.curOp and returns |
| 1511 | // the number of bytes added. |
no test coverage detected