From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27236 invoked by alias); 23 Nov 2016 02:17:15 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 27222 invoked by uid 89); 23 Nov 2016 02:17:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.8 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1640, usersystem, timer_list, 5.3.1 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 23 Nov 2016 02:17:13 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7F6ED7F081; Wed, 23 Nov 2016 02:17:12 +0000 (UTC) Received: from [127.0.0.1] (ovpn03.gateway.prod.ext.phx2.redhat.com [10.5.9.3]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uAN2HBYN019499; Tue, 22 Nov 2016 21:17:11 -0500 Subject: Re: [PATCH v2] gdb: Use C++11 std::chrono To: Simon Marchi References: <1479402927-4639-1-git-send-email-palves@redhat.com> <284edd6f2f85cd2c7cb9306a07a15b2a@polymtl.ca> Cc: gdb-patches@sourceware.org From: Pedro Alves Message-ID: <4dc8d860-16f0-65cc-796c-da240d8ffd9f@redhat.com> Date: Wed, 23 Nov 2016 02:17:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-SW-Source: 2016-11/txt/msg00659.txt.bz2 On 11/23/2016 02:01 AM, Simon Marchi wrote: > From what I understand, {user,system}_cpu_time_clock are only defined in > order to be able to use their time_point type? It feels a bit > overengineered, unless you expect those types to differ at some point. > Is there an advantage of having different types over having a single > clock type and this > > run_time_clock::now (run_time_clock::time_point &user, > run_time_clock::time_point &system) > > ? I kept them (from v1) for type-safety: it makes it impossible to swap the arguments to this new now() method by mistake, or compare old system time with new user time by mistake. E.g.: /usr/include/c++/5.3.1/chrono:650:7: note: candidate: template constexpr typename std::common_type<_Duration1, _Duration2>::type std::chrono::operator-(const std::chrono::time_point<_Clock, _Duration1>&, const std::chrono::time_point<_Clock, _Duration2>&) operator-(const time_point<_Clock, _Dur1>& __lhs, ^ /usr/include/c++/5.3.1/chrono:650:7: note: template argument deduction/substitution failed: src/gdb/mi/mi-main.c:2493:48: note: deduced conflicting types for parameter ‘_Clock’ (‘system_cpu_time_clock’ and ‘user_cpu_time_clock’) duration utime = end->stime - start->utime; ^ Would you still prefer I remove those? > Unrelated: for future work, it looks like an std::priority_queue would > be a nice match for timer_list. Maybe, but we'd need to inherit from it in order to be able to delete timers that are not at the top of the heap. A set or multiset would be other options. Thanks, Pedro Alves