Project

General

Profile

Actions

Feature #2411

closed

ContentStore API: asynchronous lookup

Added by Junxiao Shi over 9 years ago. Updated about 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Tables
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:
9.00 h

Description

Change ContentStore lookup API from:

const Data* find(const Interest& interest) const;

to:

typedef std::function<void(const Interest&, const Data&)> HitCallback;
typedef std::function<void(const Interest&)> MissCallback;
void find(const Interest& interest, HitCallback hit, MissCallback miss) const;

This allows ContentStore implementation to perform lookup operations asynchronously.

This asynchronous API enables the following use case:

On a low-memory device, it's desirable to store part of ContentStore on external storage, in order to increase the capacity of ContentStore.
A possible design is: keep the index in main memory, but store some Data packets on a flash drive.

Under such design, a ContentStore in low-memory device can synchronously determine whether a match exists, but needs to load the matched Data packet from the flash drive asynchronously.

Although the API is asynchronous and does not specify a timeout, ContentStore implementation should invoke the callback quickly (within a few milliseconds).

If the match result is already known, the callback may be invoked within find function.

Caller of find function must guarantee validity of const Interest& argument until either HitCallback or MissCallback is invoked.

The const Interest& passed to HitCallback and MissCallback is the same instance of the argument passed to find function.

const Data& passed to HitCallback is guaranteed to be valid only for the duration of this callback.
However, this Data object is always created by make_shared and therefore the callback can safely obtain shared ownership with shared_from_this in order to extend its validity.

Forwarding pipelines must be changed accordingly: the second half of "Incoming Interest pipeline" is split to "ContentStore Hit pipeline" and "ContentStore Miss pipeline".


Files


Related issues 1 (0 open1 closed)

Blocked by NFD - Feature #2185: Recognize CachingPolicy=NoCacheClosedJunxiao Shi

Actions
Actions

Also available in: Atom PDF