Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 7031A6DE103A for ; Sun, 8 Nov 2015 11:16:09 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.637 X-Spam-Level: X-Spam-Status: No, score=-0.637 tagged_above=-999 required=5 tests=[AWL=0.044, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, T_FREEMAIL_FORGED_FROMDOMAIN=0.01, T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] 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 kCIJmRHd6Dck for ; Sun, 8 Nov 2015 11:16:03 -0800 (PST) Received: from mail-qg0-f49.google.com (mail-qg0-f49.google.com [209.85.192.49]) by arlo.cworth.org (Postfix) with ESMTPS id 933AA6DE1034 for ; Sun, 8 Nov 2015 11:16:03 -0800 (PST) Received: by qgeb1 with SMTP id b1so75177603qge.1 for ; Sun, 08 Nov 2015 11:15:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:phone:user-agent; bh=n8yB1vz70OTBpkFFUYAZlp1P4WxZZOYRwhoMSQfeRtY=; b=DkftCSqDotLGkdcXvDfesqfdAR2zQzdoqdMU4/vx1Ynau5zf43fRQdKFpuSfhK2doJ iG8tKDcnDE55Iuh6Sn9I01VEfK7pKdS0GG3LwtcFQS6bQjgOtZthGhZdm6MM4ajGvSOE GgAddZMJeWyrJuNKUSSr9zd15M42UfAiWzmQKQS8oJlSV7mtsvtOixGcCcWbnVIm0cx6 88QIzJAp46Hqzbz73vEjGQ+nu446TE/MqFGwlNllMewi1ihAdaa4NyyL60yt9KFkP1OU Yt+X1jOusqDveXV2cXJKagDOSUloK7GjdEMJIEDKLNA5P0T0pPDrW9CiGiHk2Rgn7CmD UGsw== X-Received: by 10.140.28.11 with SMTP id 11mr25339985qgy.94.1447010159288; Sun, 08 Nov 2015 11:15:59 -0800 (PST) Received: from localhost (c-24-218-80-235.hsd1.ma.comcast.net. [24.218.80.235]) by smtp.gmail.com with ESMTPSA id b63sm3411616qka.31.2015.11.08.11.15.58 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Nov 2015 11:15:58 -0800 (PST) Sender: Steven Date: Sun, 8 Nov 2015 14:15:36 -0500 From: Steven Allen To: Jani Nikula Cc: notmuch@notmuchmail.org Subject: Re: [PATCH] Add a method to reparent threads to the database. Message-ID: <20151108191536.GA3115@stebalien.com> References: <1446408428-7703-1-git-send-email-steven@stebalien.com> <1446930269-4865-1-git-send-email-steven@stebalien.com> <878u6875p0.fsf@nikula.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="LZvS9be/3tNcYl/X" Content-Disposition: inline In-Reply-To: <878u6875p0.fsf@nikula.org> Phone: +1-310-433-5865 X-PGP-Key: https://stebalien.com/assets/media/uploads/key.pgp X-PGP-Fingerprint: 327B 20CE 21EA 68CF A774 8675 7C92 3221 5899 410C User-Agent: Mutt/1.5.23.1 (2014-03-12) X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.20 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, 08 Nov 2015 19:16:09 -0000 --LZvS9be/3tNcYl/X Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable I'm writing high-level rust bindings for notmuch and would like to enable encapsulation of query logic. That is, I'd like to be able to write a function that performs a (set of) query(s) and returns a (or a set of) message(s)/thread(s). I can't do this currently because the messages/threads can't outlive the query. I could use reference counting to store the query until all messages/threads have been freed but that feels messy and shouldn't, strictly speaking, be necessary. On 11-08-15, Jani Nikula wrote: > On Sat, 07 Nov 2015, Steven Allen wrote: > > This allows threads yielded from a query to outlive the query. >=20 > 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. >=20 > I think this patch makes the situation slightly worse. >=20 > I'd like to understand why this change is better than just holding on to > the query object. The memory saving is neglible. >=20 > BR, > Jani. >=20 >=20 > > --- > > 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); > > =20 > > /** > > + * Reparent a notmuch_thread_t object onto the database. > > + * > > + * Calling this function allows a notmuch_thread_t object to outlive i= ts > > + * query. The query will automatically be reclaimed when the database = is > > + * destroyed but if you want to free its memory before then, you shoul= d 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); > > +} > > --=20 > > 2.6.2 > > > > _______________________________________________ > > notmuch mailing list > > notmuch@notmuchmail.org > > https://notmuchmail.org/mailman/listinfo/notmuch --=20 Steven Allen (310) 433-5865 ((Do Not Email )) --LZvS9be/3tNcYl/X Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJWP59VAAoJEGVqlrqQ0li+qUUP+wYIs9NZRkWMZqloj7vOQk8+ AYPbtMftSXmyRg2F96wGAF3rM3NsYflVWT2qHvI6afjXpbVoq4ewVEFsN2/6lyVJ AiEFk6YwNfozUEwY4WOjZk977A07DOhY4Yw/W0wYlE9C2F+nhgSD2hlQ8ASzZDPe PG1JRe+Z9Iy2SdKZSvxn3bkSU1T+BqqCh6OETdO3lD3cPDRXvlO0c5oLdin8d5p4 JmD6V8wlDGbpCDBym8i39QuQKwPN12F3wtfv4XEBaxnuQQDYN89iZlFEoqbvuUY0 6q1Rn3pYZMJqf2eQOZqT9BsHu87Xl4q3lTypS6D1m4bMrFdLy4Vx0wzTrCYOnwo3 b3ZP9dSaCCIfVnvXhA6lBrbHDEmkCEyVtL4nQCWXYb7awvSIopmHNUjVC2idF/LN +PM8P3FoMcwnGzCwuMOk9GrUws8wLRBFh2jt95PILJMJ+bOyH5r718BuST89pySp tA1f99hupV+I2URPQbinpOq7ZODAA2dEG0O4bNm3VhQyd3UGZgMSuWspjiOJOKo3 p1ZBeYX/Gn8+q08uHNpQ4SyZj1cLmhjDbUl1nH3ktws+dHVuGfNS10H2ZbID1f6U KMgcZZc+p6R4JBpB2UQ/jzHhrPzP6WAIyuLNCYi0gCCeQKGQz2QVIyv8tL2t0tnP AVbzvXfdrtdfr36L3/r6 =on55 -----END PGP SIGNATURE----- --LZvS9be/3tNcYl/X--