aboutsummaryrefslogtreecommitdiff
path: root/src/cache.rs
diff options
context:
space:
mode:
authorDavid Li <li.davidm96@gmail.com>2016-01-25 11:39:29 -0500
committerDavid Li <li.davidm96@gmail.com>2016-01-25 11:39:53 -0500
commit0a588332811b1f45d4ae7fea74914ea29e968644 (patch)
tree94b93c189df27d353c9b60509373b7c91756c366 /src/cache.rs
parent692f250415859aea37794a1d20d89c44e62c83e3 (diff)
feat(cache): add callback for requesting new block
Diffstat (limited to 'src/cache.rs')
-rw-r--r--src/cache.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/cache.rs b/src/cache.rs
index 8b7145a..417a16d 100644
--- a/src/cache.rs
+++ b/src/cache.rs
@@ -65,6 +65,7 @@ struct Block {
}
pub trait EventHandler {
+ fn block_requested(&self, location: CacheLocation);
fn block_fetched(&self, location: CacheLocation);
}
@@ -72,6 +73,7 @@ pub struct EmptyEventHandler {}
impl EventHandler for EmptyEventHandler {
fn block_fetched(&self, _: CacheLocation) {}
+ fn block_requested(&self, _: CacheLocation) {}
}
// TODO: probably want different caches for different strategies, and
@@ -207,6 +209,7 @@ impl<'a, T: EventHandler> MemoryInterface for DirectMappedCache<'a, T> {
error: None,
waiting_on: 0,
});
+ self.events.block_requested(location);
}
else if let Some(ref mut fetch_request) = set.fetch_request {
if let Some(ref err) = fetch_request.error {