From: Jani Nikula Date: Sun, 8 Nov 2015 17:37:47 +0000 (+0200) Subject: Re: [PATCH] Add a method to reparent threads to the database. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=9595f07ca40f0dca508bca6f21340d7aa325d4a9;p=notmuch-archives.git Re: [PATCH] Add a method to reparent threads to the database. --- diff --git a/c5/fbdefbd5d463d715a9c5be3e1a45c10507172b b/c5/fbdefbd5d463d715a9c5be3e1a45c10507172b new file mode 100644 index 000000000..f5b248ef0 --- /dev/null +++ b/c5/fbdefbd5d463d715a9c5be3e1a45c10507172b @@ -0,0 +1,145 @@ +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 2F3F76DE1034 + for ; Sun, 8 Nov 2015 09:38:30 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 0.997 +X-Spam-Level: +X-Spam-Status: No, score=0.997 tagged_above=-999 required=5 tests=[AWL=1.017, + DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_MSPIKE_H3=-0.01, + RCVD_IN_MSPIKE_WL=-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 lxypank-ecVU for ; + Sun, 8 Nov 2015 09:38:27 -0800 (PST) +Received: from mail-wm0-f43.google.com (mail-wm0-f43.google.com + [74.125.82.43]) by arlo.cworth.org (Postfix) with ESMTPS id B93FA6DE0A94 for + ; Sun, 8 Nov 2015 09:38:26 -0800 (PST) +Received: by wmec201 with SMTP id c201so51961926wme.1 + for ; Sun, 08 Nov 2015 09:38:24 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=nikula_org.20150623.gappssmtp.com; s=20150623; + h=from:to:cc:subject:in-reply-to:references:user-agent:date + :message-id:mime-version:content-type; + bh=IPfVi5lZu8luU0e/TxfLs9n4Y0/J/9foPDoiPiqSBUY=; + b=NPI3qM8iYrK7NGEjDGiZequAgKrJAniF+QmD7f+14rYh+DoJKUGA94ppUku6KoxYsA + itg9/O0Y99iFb3hqd9sfysEeoh4NXaoqKw36a1W/9gLBdBjSguiAA4/Av9TY7p6i1xBr + MUj4o7YQSZF9CawY8iq4R99lQ2t2yq6EajfNzQGSrReTpqka6maVYWO7wcX3Hz3N/EjS + YO4D5+1YvbIAROsi0tmmgBq007rcVZi4Ni6aUW82l6GzWplJFpqlW6mZT3gAYMVepWxP + 9Uspbx4+UiTeZ94x0OTO7bWhoW/LvHT+TBGI37z4rQR38m+AVZ4uw3tlJr8J6BTxiNsX + 9YBw== +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:cc:subject:in-reply-to:references + :user-agent:date:message-id:mime-version:content-type; + bh=IPfVi5lZu8luU0e/TxfLs9n4Y0/J/9foPDoiPiqSBUY=; + b=LCjrsvm+x0DvFc9Uo3aFB+Sck0BQHtRg3geNdmCWU3jv9zrw3pxQQXucvVIk7xxL2p + a2JyZlF8AOAr2TvaWT3eh35NsdVVFGEcIxDsI44Q0KzAl03KnSdh+auZK58WX54YGGw6 + Mj2TBCj/x4aOyrDZwhgHNd0Fpm6g8ZhwdNy6Ap/UMdbige0QRIQbOEqv8YMQ0DdVlelh + 1FAXQqS9svg9rz/Ckic1MnB3fypY1TNcSRzFl+CDHHvRec2okd6B6UfGpE4xMYZ28dL9 + b5ZQJxaCUq3/VMQHW9T4+MgvFMfXFVO7fCJT11Vq54mizzt05Fcr7HvMmBs1trWP/p03 + meuw== +X-Gm-Message-State: + ALoCoQlINdg0fY98B5OFCDnkOERDq7vJqy6aDqsXg6IMkNqBRts/Zs29llzvi1FdvLTDgPDYjlcM +X-Received: by 10.28.30.3 with SMTP id e3mr5769933wme.78.1447004304219; + Sun, 08 Nov 2015 09:38:24 -0800 (PST) +Received: from localhost (mobile-access-5d6a91-125.dhcp.inet.fi. + [93.106.145.125]) + by smtp.gmail.com with ESMTPSA id h189sm1444873wme.1.2015.11.08.09.38.23 + (version=TLSv1/SSLv3 cipher=OTHER); + Sun, 08 Nov 2015 09:38:23 -0800 (PST) +From: Jani Nikula +To: Steven Allen , notmuch@notmuchmail.org +Cc: Steven Allen +Subject: Re: [PATCH] Add a method to reparent threads to the database. +In-Reply-To: <1446930269-4865-1-git-send-email-steven@stebalien.com> +References: <1446408428-7703-1-git-send-email-steven@stebalien.com> + <1446930269-4865-1-git-send-email-steven@stebalien.com> +User-Agent: Notmuch/0.21~rc3+3~g80a80a8 (http://notmuchmail.org) Emacs/24.4.1 + (x86_64-pc-linux-gnu) +Date: Sun, 08 Nov 2015 19:37:47 +0200 +Message-ID: <878u6875p0.fsf@nikula.org> +MIME-Version: 1.0 +Content-Type: text/plain +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 17:38:30 -0000 + +On Sat, 07 Nov 2015, Steven Allen 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