unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Jani Nikula <jani@nikula.org>
To: Steven Allen <steven@stebalien.com>, notmuch@notmuchmail.org
Cc: Steven Allen <steven@stebalien.com>
Subject: Re: [PATCH] Add a method to reparent threads to the database.
Date: Sun, 08 Nov 2015 19:37:47 +0200	[thread overview]
Message-ID: <878u6875p0.fsf@nikula.org> (raw)
In-Reply-To: <1446930269-4865-1-git-send-email-steven@stebalien.com>

On Sat, 07 Nov 2015, Steven Allen <steven@stebalien.com> wrote:
> This allows threads yielded from a query to outlive the query.

We have a leaky abstraction in the interface. We don't properly define
object lifetimes and ownership, but we have slightly vague references to
them, and the users of the interface pretty much have to respect
them. We try to hide talloc and its concepts.

I think this patch makes the situation slightly worse.

I'd like to understand why this change is better than just holding on to
the query object. The memory saving is neglible.

BR,
Jani.


> ---
>  lib/notmuch.h | 11 +++++++++++
>  lib/thread.cc |  6 ++++++
>  2 files changed, 17 insertions(+)
>
> diff --git a/lib/notmuch.h b/lib/notmuch.h
> index 310a8b8..9a2869b 100644
> --- a/lib/notmuch.h
> +++ b/lib/notmuch.h
> @@ -1188,6 +1188,17 @@ notmuch_tags_t *
>  notmuch_thread_get_tags (notmuch_thread_t *thread);
>  
>  /**
> + * Reparent a notmuch_thread_t object onto the database.
> + *
> + * Calling this function allows a notmuch_thread_t object to outlive its
> + * query. The query will automatically be reclaimed when the database is
> + * destroyed but if you want to free its memory before then, you should call
> + * notmuch_thread_destroy.
> + */
> +void
> +notmuch_thread_own (notmuch_thread_t *thread);
> +
> +/**
>   * Destroy a notmuch_thread_t object.
>   */
>  void
> diff --git a/lib/thread.cc b/lib/thread.cc
> index 0c937d7..06fa155 100644
> --- a/lib/thread.cc
> +++ b/lib/thread.cc
> @@ -623,3 +623,9 @@ notmuch_thread_destroy (notmuch_thread_t *thread)
>  {
>      talloc_free (thread);
>  }
> +
> +void
> +notmuch_thread_own (notmuch_thread_t *thread)
> +{
> +    talloc_steal (thread->notmuch, thread);
> +}
> -- 
> 2.6.2
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch

  reply	other threads:[~2015-11-08 17:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-01 20:07 [PATCH] Add method to reparent of message to the database Steven Allen
2015-11-07 21:04 ` [PATCH] Add a method to reparent threads " Steven Allen
2015-11-08 17:37   ` Jani Nikula [this message]
2015-11-08 19:15     ` Steven Allen
2017-03-11 22:44       ` David Bremner

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=878u6875p0.fsf@nikula.org \
    --to=jani@nikula.org \
    --cc=notmuch@notmuchmail.org \
    --cc=steven@stebalien.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).