From 108e9d547ff1bbc5501e03208dc5ea33d4b7c729 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Wed, 7 Sep 2016 17:58:57 +0200 Subject: [PATCH] added Utilities::rusage --- src/uvw/util.hpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/uvw/util.hpp b/src/uvw/util.hpp index 1adc451d..abb842a4 100644 --- a/src/uvw/util.hpp +++ b/src/uvw/util.hpp @@ -172,6 +172,9 @@ using Stat = uv_stat_t; using Uid = uv_uid_t; using Gid = uv_gid_t; +using TimeVal = uv_timeval_t; +using RUsage = uv_rusage_t; + /** * @brief The IPv4 tag. @@ -522,6 +525,16 @@ struct Utilities { return ret; } + /** + * @brief Gets the resource usage measures for the current process. + * @return Resource usage measures, zeroes-filled object in case of errors. + */ + static RUsage rusage() noexcept { + RUsage ru; + auto err = uv_getrusage(&ru); + return err ? RUsage{} : ru; + } + /** * @brief Gets the current high-resolution real time. * @@ -566,7 +579,6 @@ struct Utilities { /** * TODO * - * * uv_getrusage * * uv_os_homedir * * uv_os_tmpdir * * uv_os_get_passwd