Re: [PATCH spice-streaming-agent 2/9] FrameLog: Use std::chrono instead of gettimeofday for time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 
> Signed-off-by: Lukáš Hrázký <lhrazky@xxxxxxxxxx>

Patch looks good but would be good to state the reasons.
Portability?
Just style?
Has the new implementation the same precision and efficiency?

> ---
>  src/frame-log.cpp | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/src/frame-log.cpp b/src/frame-log.cpp
> index b0bd09e..4418d09 100644
> --- a/src/frame-log.cpp
> +++ b/src/frame-log.cpp
> @@ -9,9 +9,9 @@
>  #include "error.hpp"
>  #include "hexdump.h"
>  
> +#include <chrono>
>  #include <cstdarg>
>  #include <string.h>
> -#include <sys/time.h>
>  
>  
>  namespace spice {
> @@ -67,10 +67,9 @@ void FrameLog::log_frame(const void* buffer, size_t
> buffer_size)
>   */
>  uint64_t FrameLog::get_time()
>  {
> -    struct timeval now;
> -    gettimeofday(&now, NULL);
> -
> -    return (uint64_t)now.tv_sec * 1000000 + (uint64_t)now.tv_usec;
> +    auto now = std::chrono::system_clock::now().time_since_epoch();
> +    return
> std::chrono::duration_cast<std::chrono::microseconds>(now).count();
>  }
>  
> +

Spurious line change

>  }} // namespace spice::streaming_agent

Frediano
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]