From patchwork Wed Nov 27 08:49:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 2382 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B51D06136B for ; Wed, 27 Nov 2019 09:49:27 +0100 (CET) Received: from pendragon.tok.corp.google.com (unknown [104.132.253.101]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B7044A4B for ; Wed, 27 Nov 2019 09:49:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1574844567; bh=X15X8SXF65v7Cq9Gi4Wh3gw23f0cVIhwEcOEFKzQuM4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=uL4853olEttDQthx8keJxYBG3jO06AHUHJbegiQyQSci4h/E+QVdOgOlEyUUIb2LV 8dipTLyOX3arGX0ajkYcpqWI4u0+b4y11b5363QuaK4l+QBrygU8yIr6woWW3EvkFO b9Og15dFKr0YgBAN8Ap6GGYtRJPiYoWZgq+2UpZM= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Wed, 27 Nov 2019 10:49:08 +0200 Message-Id: <20191127084909.10612-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191127084909.10612-1-laurent.pinchart@ideasonboard.com> References: <20191127084909.10612-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/5] libcamera: object: Document danger of deleting object from other thread X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Nov 2019 08:49:28 -0000 Object instances receive messages dispatched from the event loop of the thread they belong to. Deleting an object from a different thread is thus dangerous, unless the caller ensures that no message delivery is in progress. Document this in the Object class documentation. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- src/libcamera/object.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libcamera/object.cpp b/src/libcamera/object.cpp index 1f787271f782..e76faf48b8ed 100644 --- a/src/libcamera/object.cpp +++ b/src/libcamera/object.cpp @@ -40,6 +40,10 @@ LOG_DEFINE_CATEGORY(Object) * implementing easy message passing between threads by inheriting from the * Object class. * + * Deleting an object from a thread other than the one the object is bound to is + * unsafe, unless the caller ensures that the object isn't processing any + * message concurrently. + * * Object slots connected to signals will also run in the context of the * object's thread, regardless of whether the signal is emitted in the same or * in another thread.