From 7721aa5643a238c530955972779283cfc3aaaf42 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Thu, 28 Jul 2016 17:03:11 -0400 Subject: [PATCH] api: Add value creation timepoint (#97) --- include/opendht/dhtrunner.h | 14 +++++++------- src/dhtrunner.cpp | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/opendht/dhtrunner.h b/include/opendht/dhtrunner.h index 47f97070..0dd3ad26 100644 --- a/include/opendht/dhtrunner.h +++ b/include/opendht/dhtrunner.h @@ -161,16 +161,16 @@ public: void cancelListen(InfoHash h, size_t token); void cancelListen(InfoHash h, std::shared_future token); - void put(InfoHash hash, std::shared_ptr value, DoneCallback cb={}, bool permanent = false); - void put(InfoHash hash, std::shared_ptr value, DoneCallbackSimple cb, bool permanent = false) { - put(hash, value, bindDoneCb(cb), permanent); + void put(InfoHash hash, std::shared_ptr value, DoneCallback cb={}, time_point created=time_point::max(), bool permanent = false); + void put(InfoHash hash, std::shared_ptr value, DoneCallbackSimple cb, time_point created=time_point::max(), bool permanent = false) { + put(hash, value, bindDoneCb(cb), created, permanent); } - void put(InfoHash hash, Value&& value, DoneCallback cb={}, bool permanent = false); - void put(InfoHash hash, Value&& value, DoneCallbackSimple cb, bool permanent = false) { - put(hash, std::forward(value), bindDoneCb(cb), permanent); + void put(InfoHash hash, Value&& value, DoneCallback cb={}, time_point created=time_point::max(), bool permanent = false); + void put(InfoHash hash, Value&& value, DoneCallbackSimple cb, time_point created=time_point::max(), bool permanent = false) { + put(hash, std::forward(value), bindDoneCb(cb), created, permanent); } - void put(const std::string& key, Value&& value, DoneCallbackSimple cb={}, bool permanent = false); + void put(const std::string& key, Value&& value, DoneCallbackSimple cb={}, time_point created=time_point::max(), bool permanent = false); void cancelPut(const InfoHash& h, const Value::Id& id); diff --git a/src/dhtrunner.cpp b/src/dhtrunner.cpp index 8a8cc01b..b13ca77e 100644 --- a/src/dhtrunner.cpp +++ b/src/dhtrunner.cpp @@ -491,30 +491,30 @@ DhtRunner::cancelListen(InfoHash h, std::shared_future token) } void -DhtRunner::put(InfoHash hash, Value&& value, DoneCallback cb, bool permanent) +DhtRunner::put(InfoHash hash, Value&& value, DoneCallback cb, time_point created, bool permanent) { std::lock_guard lck(storage_mtx); auto sv = std::make_shared(std::move(value)); pending_ops.emplace([=](SecureDht& dht) { - dht.put(hash, sv, cb, {}, permanent); + dht.put(hash, sv, cb, created, permanent); }); cv.notify_all(); } void -DhtRunner::put(InfoHash hash, std::shared_ptr value, DoneCallback cb, bool permanent) +DhtRunner::put(InfoHash hash, std::shared_ptr value, DoneCallback cb, time_point created, bool permanent) { std::lock_guard lck(storage_mtx); pending_ops.emplace([=](SecureDht& dht) { - dht.put(hash, value, cb, {}, permanent); + dht.put(hash, value, cb, created, permanent); }); cv.notify_all(); } void -DhtRunner::put(const std::string& key, Value&& value, DoneCallbackSimple cb, bool permanent) +DhtRunner::put(const std::string& key, Value&& value, DoneCallbackSimple cb, time_point created, bool permanent) { - put(InfoHash::get(key), std::forward(value), cb, permanent); + put(InfoHash::get(key), std::forward(value), cb, created, permanent); } void