unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: rhn <nomumali.rhn@porcupinefactory.org>
To: David Bremner <david@tethera.net>
Cc: Dirk Van Haerenborgh <vhdirk@gmail.com>, notmuch@notmuchmail.org
Subject: Re: Pointer ownership
Date: Sun, 23 Dec 2018 11:04:55 +0100	[thread overview]
Message-ID: <20181223110455.395adcfb.rhn@porcupinefactory.org> (raw)
In-Reply-To: <87imzt9hvw.fsf@tethera.net>

On Mon, 17 Dec 2018 08:22:27 +0900
David Bremner <david@tethera.net> wrote:

> Dirk Van Haerenborgh <vhdirk@gmail.com> 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

      parent reply	other threads:[~2018-12-23 10:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-16  7:42 Pointer ownership Dirk Van Haerenborgh
2018-12-16 23:22 ` David Bremner
2018-12-20  9:21   ` Dirk Van Haerenborgh
2018-12-22  6:11     ` David Bremner
2018-12-23 10:04   ` rhn [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181223110455.395adcfb.rhn@porcupinefactory.org \
    --to=nomumali.rhn@porcupinefactory.org \
    --cc=david@tethera.net \
    --cc=notmuch@notmuchmail.org \
    --cc=vhdirk@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).