From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 5AED76DE023C for ; Sun, 23 Dec 2018 02:12:40 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.362 X-Spam-Level: X-Spam-Status: No, score=0.362 tagged_above=-999 required=5 tests=[KHOP_DYNAMIC=0.001, RDNS_DYNAMIC=0.363, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id accV2jZyd3ck for ; Sun, 23 Dec 2018 02:12:39 -0800 (PST) X-Greylist: delayed 457 seconds by postgrey-1.36 at arlo; Sun, 23 Dec 2018 02:12:39 PST Received: from porcupinefactory.org (91.218.216.54.siec.idealan.pl [91.218.216.54]) by arlo.cworth.org (Postfix) with ESMTPS id 385596DE022E for ; Sun, 23 Dec 2018 02:12:39 -0800 (PST) Received: from porcupinefactory.org (unknown [192.168.6.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by porcupinefactory.org (Postfix) with ESMTPSA id 2C725679852; Sun, 23 Dec 2018 11:04:20 +0100 (CET) Date: Sun, 23 Dec 2018 11:04:55 +0100 From: rhn To: David Bremner Cc: Dirk Van Haerenborgh , notmuch@notmuchmail.org Subject: Re: Pointer ownership Message-ID: <20181223110455.395adcfb.rhn@porcupinefactory.org> In-Reply-To: <87imzt9hvw.fsf@tethera.net> References: <87imzt9hvw.fsf@tethera.net> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Dec 2018 10:12:40 -0000 On Mon, 17 Dec 2018 08:22:27 +0900 David Bremner wrote: > Dirk Van Haerenborgh writes: > > > > For instance, when iterating messages from a thread: Can one still use a > > notmuch_message_t* when the thread is destroyed? > > Are the individual > > messages 'owned' by the thread, or only by the query? Same question for > > 'replies'. > > > > Could someone please shed some light on this? I'd very much appreciate it. > > It's hierarchical (the underlying allocator is talloc). So threads are > owned by the corresponding query, and messages are owned by threads. > > Assuming replies refers to notmuch_message_get_replies, then those are > owned by some thread as well. > > Threads are somewhat lazily constructed, so there's a time where a > message is owned by a query before it is "stolen" by a thread. > > This is all Carl's design, so hopefully he'll correct me if I said > anything outrageously wrong. > > d > Thanks for the answer. When you're saying that threads are "lazily constructed", I assume that it doesn't really matter for the actual API? From that, I'm guessing that the message handover starts and ends within a single API call, before the caller ever has a chance to see the message handle? The importance of lifetimes in Rust only concerns what the API guarantees about the validity of handles/data, so the implementation is free to do whatever as long as those are not impacted. BTW, I've submitted a patch making the guarantee explicitly stated in the docs, see 20181217175748.10814-1-gihu.rhn@porcupinefactory.org . Reviews welcome, a merge is even more welcome. Cheers, rhn