From 13c503b73b4ecc8ce4a6e344f9ac15202985d686 Mon Sep 17 00:00:00 2001
From: liuxiaolong <liuxiaolong@aiotlink.com>
Date: 星期二, 20 七月 2021 19:48:58 +0800
Subject: [PATCH] fix memory leak

---
 src/robust.h |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/robust.h b/src/robust.h
index c46010a..1a3f430 100644
--- a/src/robust.h
+++ b/src/robust.h
@@ -67,6 +67,8 @@
 	typedef std::function<Data(const Data)> Handler;
 	bool ClientRequest(const Data request, Data &reply);
 	bool ServerProcess(Handler onReq);
+	AtomicReqRep() :
+	    data_(0), timestamp_(now()) {}
 
 private:
 	enum State {
@@ -79,7 +81,7 @@
 	static Data Decode(Data d) { return d >> 3; }
 	typedef std::chrono::steady_clock steady_clock;
 	typedef steady_clock::duration Duration;
-	Duration now() { return steady_clock::now().time_since_epoch(); }
+	static Duration now() { return steady_clock::now().time_since_epoch(); }
 
 	bool DataCas(Data expected, Data val) { return data_.compare_exchange_strong(expected, val); }
 	std::atomic<Data> data_;

--
Gitblit v1.8.0