From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) by sourceware.org (Postfix) with ESMTPS id E87E63858025 for ; Tue, 29 Mar 2022 17:36:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E87E63858025 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f53.google.com with SMTP id h23so25868889wrb.8 for ; Tue, 29 Mar 2022 10:36:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=6TikCtYpxDgjEvmwswqdLB0I+P2FpwrdVpsYROz8zr0=; b=ySqxIe50L/u6BbBCpBY4QlVzJbRRDPYhKeFJwLM4pTtIFLDtleTOyMX3YXTIw+g1Te xbTySXkF6ptKMP4Q1BCo8rXyoe5A1ip/bK/rUw84w73cowgBZjVFZO8A92irl5yLDPUl 11IgcwIqRjQG9X+ICAc+bF/rQaVNus+gMwxOm/EoMfdC1T1Mh2qHBu2MsnDhJyuMGyu1 mBNdOvRBHuh1v+h5aaFI11tiAoqje8QCiWZgz72+L5pb4ChW1vueFjL+vU38fu6WrO2W HtwETReMg2r7PL7APxJv+DsNtecNSpFLD3Lbn1LUFi6dbUprVT4tLXJEnP/ekv4rx63Y rBUw== X-Gm-Message-State: AOAM5317i2eJfmvnoDwabG1r5rsk3b5RpXN5XsHnzbtxVqc22+sLnLWL UYVViAYvEMqVbKWT3flv9Qk= X-Google-Smtp-Source: ABdhPJwhxaafsV+P9pKq9dNbKdGoxg4mepSnSEVb5L6Dy8TsZdssOctsIOjnA/fIgVdRJHCaxzy+1w== X-Received: by 2002:a5d:6b0b:0:b0:1ef:d826:723a with SMTP id v11-20020a5d6b0b000000b001efd826723amr33461828wrw.420.1648575406569; Tue, 29 Mar 2022 10:36:46 -0700 (PDT) Received: from ?IPV6:2001:8a0:f924:2600:209d:85e2:409e:8726? ([2001:8a0:f924:2600:209d:85e2:409e:8726]) by smtp.gmail.com with ESMTPSA id m20-20020a05600c4f5400b0038b5162260csm3933151wmq.23.2022.03.29.10.36.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 29 Mar 2022 10:36:45 -0700 (PDT) Message-ID: <554a3904-c777-02cb-1a04-cb635e0ee742@palves.net> Date: Tue, 29 Mar 2022 18:36:44 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH v3 11/33] Return vector of results from parallel_for_each Content-Language: en-US To: Tom Tromey , gdb-patches@sourceware.org References: <20211204203844.1188999-1-tom@tromey.com> <20211204203844.1188999-12-tom@tromey.com> From: Pedro Alves In-Reply-To: <20211204203844.1188999-12-tom@tromey.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Mar 2022 17:36:49 -0000 Hi Tom, Just a nit that I noticed while skimming the series. (please don't wait for a full review of the series from me.) On 2021-12-04 20:38, Tom Tromey wrote: > + /* Invoke TASK in the current thread, then compute all the results > + from all background tasks and put them into a result vector, > + which is returned. */ > + result_type finish (std::function task) Since TASK is always executed in the current thread, it can be a gdb::function_view instead of a std::function. > + { > + result_type result (m_futures.size () + 1); > + > + result.back () = task (); > + > + for (size_t i = 0; i < m_futures.size (); ++i) > + result[i] = m_futures[i].get (); > + > + return result; > + } > + > +private: > + > + result_type finish (std::function task) > + { Ditto for the void specialization. > + task (); > + > + for (auto &future : m_futures) > + { > + /* Use 'get' and not 'wait', to propagate any exception. */ > + future.get (); > + } > + } > +