From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 50870 invoked by alias); 2 Jul 2019 12:00:49 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 50849 invoked by uid 89); 2 Jul 2019 12:00:49 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=H*i:sk:3dc7173, H*f:sk:3dc7173 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; Tue, 02 Jul 2019 12:00:48 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0EC95301EA82; Tue, 2 Jul 2019 12:00:47 +0000 (UTC) Received: from localhost (unknown [10.33.36.121]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A9CC7E119; Tue, 2 Jul 2019 12:00:46 +0000 (UTC) Date: Tue, 02 Jul 2019 12:00:00 -0000 From: Jonathan Wakely To: mingw-w64-public@lists.sourceforge.net Cc: Liu Hao , Eric Botcazou , libstdc++@gcc.gnu.org, GCC Patches Subject: Re: [Mingw-w64-public] Fwd: [patch] Reimplement GNU threads library on native Windows Message-ID: <20190702120033.GJ4665@redhat.com> References: <2175092.5hV0XgF4mA@polaris> <30ed46f2-6672-f805-9627-05c31c8a708e@codeweavers.com> <715159ed-1f9b-768e-8ac1-130d0dcbbfd1@126.com> <2395489.buBb56uQH1@polaris> <20437f86-a861-4e70-7e84-d623652bb73e@codeweavers.com> <3dc7173a-75e9-006a-8bb6-cd1459897b6e@codeweavers.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3dc7173a-75e9-006a-8bb6-cd1459897b6e@codeweavers.com> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.11.3 (2019-02-01) X-SW-Source: 2019-07/txt/msg00138.txt.bz2 On 02/07/19 12:15 +0200, Jacek Caban wrote: > >On 02/07/2019 12:12, Jacek Caban wrote: >>On 02/07/2019 11:57, Liu Hao wrote: >> >>>在 2019/7/2 下午5:19, Eric Botcazou 写道: >>>>>It seems inappropriate to use handles as thread identifiers >>>>>(as handles >>>>>imply resource ownership and are not unique identifiers); >>>>>thread IDs (as >>>>>`DWORD` or `unsigned long`) would be a better alternative. >>>>This was considered but ultimately rejected, as you can do >>>>nothing with a >>>>thread Id, i.e. you need a handle for everything.  But the >>>>__gthread_equal >>>>routine does compare the Ids and not the handles. >>>> >>>The `OpenThread()` function can obtain a handle by thread ID. It returns >>>a real handle that has to be closed when it is out of use. Using the >>>pseudo handle returned by `GetCurrentThread()` may be more efficient if >>>the target thread ID is equal to `GetCurrentThreadId()`. >> >> >>The problem with thread id is that it's not valid nor guaranteed to >>be identical after the thread is terminated. A handle needs to be >>used for that. > > >I meant unique, not identical. The C++ standard says: "The library may reuse the value of a thread::id of a terminated thread that can no longer be joined." So that's not a reason to use a handle.