399 | | fetch_items(index, index); // FIXME: this checks indexeddocs AGAIN! |
400 | | /* Actually read the fetched documents */ |
401 | | read_docs(); |
402 | | Assert(indexeddocs.find(index) != indexeddocs.end()); |
403 | | Assert(indexeddocs.find(index)->first == index); // Paranoid assert |
404 | | RETURN(indexeddocs.find(index)->second); |
| 399 | Assert(enquire.get()); |
| 400 | if (!requested_docs.empty()) { |
| 401 | // There's already a pending request, so handle that. |
| 402 | read_docs(); |
| 403 | // Maybe we just fetched the doc we want. |
| 404 | doc = indexeddocs.find(index); |
| 405 | if (doc != indexeddocs.end()) { |
| 406 | RETURN(doc->second); |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | // Don't cache unless fetch() was called by the API user. |
| 411 | enquire->request_doc(items[index - firstitem]); |
| 412 | RETURN(enquire->read_doc(items[index - firstitem])); |