Preconditions: - All pages in fr must be becoming waste pages. - fr must be page-aligned.
(fr memmap.FileRange)
| 1922 | // - All pages in fr must be becoming waste pages. |
| 1923 | // - fr must be page-aligned. |
| 1924 | func (amfl *asyncMemoryFileLoad) cancelWasteLoad(fr memmap.FileRange) { |
| 1925 | // Lockless fast path: |
| 1926 | if fr.End <= amfl.minUnloaded.Load() { |
| 1927 | return |
| 1928 | } |
| 1929 | |
| 1930 | amfl.pf.mu.Lock() |
| 1931 | defer amfl.pf.mu.Unlock() |
| 1932 | amfl.unloaded.RemoveRangeWith(fr, func(ulseg aplUnloadedIterator) { |
| 1933 | ul := ulseg.ValuePtr() |
| 1934 | if ul.started { |
| 1935 | // This shouldn't be possible since page references are held while |
| 1936 | // reading (see MemoryFile.asyncPageLoadMain()). |
| 1937 | panic(fmt.Sprintf("pages %v becoming waste during inflight read from async loading", ulseg.Range())) |
| 1938 | } |
| 1939 | if n := len(ul.waiters); n != 0 { |
| 1940 | // This shouldn't be possible since the waiters should hold page |
| 1941 | // references. |
| 1942 | panic(fmt.Sprintf("pages %v becoming waste with %d async load waiters", ulseg.Range(), n)) |
| 1943 | } |
| 1944 | }) |
| 1945 | } |
| 1946 | |
| 1947 | type aplUnloadedSetFunctions struct{} |
| 1948 |