You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by GitBox <gi...@apache.org> on 2022/10/24 13:21:40 UTC

[GitHub] [incubator-kvrocks] PragmaTwice commented on a diff in pull request #1038: Use a consistent way to get the current time

PragmaTwice commented on code in PR #1038:
URL: https://github.com/apache/incubator-kvrocks/pull/1038#discussion_r1003306587


##########
src/common/util.h:
##########
@@ -68,6 +68,7 @@ std::vector<std::string> TokenizeRedisProtocol(const std::string &value);
 
 void ThreadSetName(const char *name);
 int aeWait(int fd, int mask, uint64_t milliseconds);
+int64_t GetTimeStamp();
 uint64_t GetTimeStampMS();
 uint64_t GetTimeStampUS();

Review Comment:
   ```suggestion
   template <typename Duration = std::chrono::seconds>
   auto GetTimeStamp() -> typename Duration::rep {
     return std::chrono::duration_cast<Duration>(std::chrono::system_clock::now().time_since_epoch()).count();
   }
   uint64_t GetTimeStampMS() { return GetTimeStamp<std::chrono::milliseconds>(); }
   uint64_t GetTimeStampUS() { return GetTimeStamp<std::chrono::microseconds>(); }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org