Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ namespace hazelcast {
void innerClose();

std::chrono::steady_clock::time_point startTime;
std::atomic<std::chrono::steady_clock::time_point> closedTime;
std::atomic<std::chrono::steady_clock::duration> closedTimeDuration;
spi::ClientContext &clientContext;
protocol::IMessageHandler &invocationService;
std::unique_ptr<Socket> socket;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace hazelcast {
private:

protocol::ClientMessageBuilder builder;
std::atomic<std::chrono::steady_clock::time_point> lastReadTime;
std::atomic<std::chrono::steady_clock::duration> lastReadTimeDuration;
};
}
}
Expand Down
11 changes: 6 additions & 5 deletions hazelcast/src/hazelcast/client/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -863,15 +863,15 @@ namespace hazelcast {

ReadHandler::ReadHandler(Connection &connection, size_t bufferSize)
: buffer(new char[bufferSize]), byteBuffer(buffer, bufferSize), builder(connection),
lastReadTime(std::chrono::steady_clock::now()) {
lastReadTimeDuration(std::chrono::steady_clock::now().time_since_epoch()) {
}

ReadHandler::~ReadHandler() {
delete[] buffer;
}

void ReadHandler::handle() {
lastReadTime = std::chrono::steady_clock::now();
lastReadTimeDuration = std::chrono::steady_clock::now().time_since_epoch();

if (byteBuffer.position() == 0)
return;
Expand All @@ -891,7 +891,7 @@ namespace hazelcast {
}

const std::chrono::steady_clock::time_point ReadHandler::getLastReadTime() const {
return lastReadTime;
return std::chrono::steady_clock::time_point(lastReadTimeDuration);
}

Connection::Connection(const Address &address, spi::ClientContext &clientContext, int connectionId,
Expand All @@ -902,6 +902,7 @@ namespace hazelcast {
boost::asio::ip::tcp::resolver &resolver)
: readHandler(*this, 16 << 10),
startTime(std::chrono::steady_clock::now()),
closedTimeDuration(),
clientContext(clientContext),
invocationService(clientContext.getInvocationService()),
authFuture(authFuture),
Expand Down Expand Up @@ -945,7 +946,7 @@ namespace hazelcast {
return;
}

closedTime.store(std::chrono::steady_clock::now());
closedTimeDuration.store(std::chrono::steady_clock::now().time_since_epoch());

closeCause = cause;
closeReason = reason;
Expand Down Expand Up @@ -1112,7 +1113,7 @@ namespace hazelcast {
os << "null";
}
os << ", lastReadTime=" << util::StringUtil::timeToString(conn.lastReadTime())
<< ", closedTime=" << util::StringUtil::timeToString(conn.closedTime)
<< ", closedTime=" << util::StringUtil::timeToString(std::chrono::steady_clock::time_point(conn.closedTimeDuration))
<< ", connected server version=" << conn.connectedServerVersionString
<< '}';

Expand Down