From patchwork Tue Nov 6 21:38:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 150351 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4417440ljp; Tue, 6 Nov 2018 13:54:58 -0800 (PST) X-Google-Smtp-Source: AJdET5ew5GKd8rncAfplWH22x3YehYjWClOTrP/y1owfvA7je4h8o0JuzV9SWxwvkgJll2XPAbQs X-Received: by 2002:ac8:1779:: with SMTP id u54mr21944801qtk.285.1541541298506; Tue, 06 Nov 2018 13:54:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541541298; cv=none; d=google.com; s=arc-20160816; b=NHaduc3q9R/eXZaOWzig0g+rsvpKpraF0zV66Fxcrdigk1em9sD/BWmZIXKsxb318X DiXN5sbAULA+9aONmGq/if5lW+ypaiP01gkvnZ82usOoYvc8RJLWdb3wn0a40zjlrrQp 4bBPH1gsu5V4N2DIT36ScG8E8EwVBXIAgQzx4b1gtd4GhK5FfMOTXEUOFJMzmPrFjTAR 3Jmx6vAkp3IESb3pH4vGGZraTTNRGhQpU6VMx5eBTGU3stHoJtvnzH8o3iRDGPFZk7ab rXsubq+raVygKM8YNRcRXdTltfO+IdRLhz8g4VZ3lMGuqondZW0uSJNJz6ycOdPj8rJL NnRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=UXoBODQ4wFCYIlqvkFPG8T7sKKFLZ2kBSRrAKTUr30M=; b=GNNSQGaKNBVwBNbfl03uTIJNUE92EpuiCgdXddF5EzYZzbrNzEdQEYrQz+6IaQlPqW c1FWz2O4cZXrmn6eyjHVjA55TgxmLUPjzqHUA2VNpVYrCAxDztJn0w8YilKstBWFtg0W 43DTYDopnke5HXEp5+CsPRcft6cJY43JY+l/vIGG1BVFNgwKoGYHiVoITtDMaRImGbDt Gv2t6KRtVsLCgW4oHp6sIEGXanYK1zwUmJ4nJbxMikYAAWrN4+9KsjjHTc2SBVSQpZ+i /ym1IIHLYMBNMrLGp0GgLSWLsZtakMaHyzxFYDKGIP20XUzuM13Zhv4IpwoUczxRIFD1 AZxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=peGNQ+ov; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id y65si6601840qky.128.2018.11.06.13.54.58 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 06 Nov 2018 13:54:58 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=peGNQ+ov; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:43945 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9JK-0005Ye-0G for patch@linaro.org; Tue, 06 Nov 2018 16:54:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40147) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK9Cr-0002lH-Fw for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:48:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gK93U-0001I6-GZ for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:40 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:55902) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gK93T-0000eE-Tu for qemu-devel@nongnu.org; Tue, 06 Nov 2018 16:38:36 -0500 Received: by mail-wm1-x334.google.com with SMTP id s10-v6so12270239wmc.5 for ; Tue, 06 Nov 2018 13:38:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=UXoBODQ4wFCYIlqvkFPG8T7sKKFLZ2kBSRrAKTUr30M=; b=peGNQ+ovJUcDjNAt5LnZDxxXBWhILu8wWVmblJ0LOmlrAtAfjjdYVPv/pDbMpV8SUA ujUnTNQhL2Or5BCZA7yycxP8+bkOI4nwmGgu+jYGx7bsaL+5Iv9jHQHRwQTn5vOjsORs IAD9N3uOPh62DUB4hqrfIRpYBXq/K+6rbu3KSebS4smI8Fj40FUbSSftI05k4ldUiBN3 KF/jH/DM9QPJzvB7VU1Y8+sbu5hCuWwADpa2ZtMHpuINjyGcLY5tF8SMzNTh1Gee6kbV /pTmKVsgn/znBCTStS/WAEUKxRkj2Mz7/k2LNk0/7TkNnPq5eypa9YBAvR+9wgIA8JZO 0v5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=UXoBODQ4wFCYIlqvkFPG8T7sKKFLZ2kBSRrAKTUr30M=; b=poy06HCn2sS39HpZRZ2A3qAE63ESIdeQDKZsKAAZl/RkvWg8oMxrgI34xq/f+sJxL0 GoP0q1e/TpyclaEsZWiV/KJiuU6uwwOt8Roq9x8o5X4xTP4bQFp5kexcEycJydNVzIp2 SE6DAkvoD8/YpeF72soWIiUeWq1iea9Ig120XTe/r5Y69nEMQeXeT9GppKg21802lBgz Y0V2i/L0ari8KBestDI7Fu1xURgKoyxfK22tEMMiv7ccjoJDY//dbH7NmUtq3/UssQgT zkq/P7YmsqSuHxyD7D268qf2tohbq85EuGj732azMf9GWGhlQcORcOC5enybvFqfpKZV XP5g== X-Gm-Message-State: AGRZ1gJGSDEXG99tMikOaFKgutITFgGDnB+tM2U//y7AESVKtCpoKawC XOKmxju7zhYjSP4UvQp2q95AAzRD X-Received: by 2002:a1c:5447:: with SMTP id p7-v6mr664772wmi.129.1541540304212; Tue, 06 Nov 2018 13:38:24 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id l186-v6sm3223526wma.13.2018.11.06.13.38.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 13:38:23 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 6 Nov 2018 22:38:02 +0100 Message-Id: <1541540283-45699-17-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> References: <1541540283-45699-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::334 Subject: [Qemu-devel] [PULL 16/17] include/qemu/thread.h: Document qemu_thread_atexit* API X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell Add documentation for the qemu_thread_atexit_add() and qemu_thread_atexit_remove() functions. We include a (previously undocumented) constraint that notifiers may not be called if a thread is exiting because the entire process is exiting. This is fine for our current use because the callers use it only for cleaning up resources which go away on process exit (memory, Win32 fibers), and we will need the flexibility for the new posix implementation. Signed-off-by: Peter Maydell Reviewed-by: Eric Blake Message-Id: <20181105135538.28025-2-peter.maydell@linaro.org> Signed-off-by: Paolo Bonzini --- include/qemu/thread.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) -- 1.8.3.1 diff --git a/include/qemu/thread.h b/include/qemu/thread.h index b2661b6..55d83a9 100644 --- a/include/qemu/thread.h +++ b/include/qemu/thread.h @@ -162,7 +162,29 @@ void qemu_thread_exit(void *retval); void qemu_thread_naming(bool enable); struct Notifier; +/** + * qemu_thread_atexit_add: + * @notifier: Notifier to add + * + * Add the specified notifier to a list which will be run via + * notifier_list_notify() when this thread exits (either by calling + * qemu_thread_exit() or by returning from its start_routine). + * The usual usage is that the caller passes a Notifier which is + * a per-thread variable; it can then use the callback to free + * other per-thread data. + * + * If the thread exits as part of the entire process exiting, + * it is unspecified whether notifiers are called or not. + */ void qemu_thread_atexit_add(struct Notifier *notifier); +/** + * qemu_thread_atexit_remove: + * @notifier: Notifier to remove + * + * Remove the specified notifier from the thread-exit notification + * list. It is not valid to try to remove a notifier which is not + * on the list. + */ void qemu_thread_atexit_remove(struct Notifier *notifier); struct QemuSpin {