From patchwork Fri Aug 27 02:38:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13521 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id B24FABD87D for ; Fri, 27 Aug 2021 02:38:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9A9D76893F; Fri, 27 Aug 2021 04:38:47 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="VXWxVhzy"; dkim-atps=neutral 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 161DE60288 for ; Fri, 27 Aug 2021 04:38:46 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 869655A1 for ; Fri, 27 Aug 2021 04:38:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1630031925; bh=WlhALTuS8V7wFxvs8ERD8VhtzPJVvxqD4Dt6ptls9C0=; h=From:To:Subject:Date:From; b=VXWxVhzyndmEXb2yc9ugps6d+NJ0vnngTpU4k+UVBmjVJL3gy85EVc+5E4CSXy+4Z 5Yo9gQarop2LZtX31fNJNp8Mo5Ac2zpyu8v/2pq8FpaMPhoO6X1iB5c2Oi6vp6/xfG B4l70Nbyg6iBjU8qGigFcmZjqcwRMAlUbfn8LggE= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 27 Aug 2021 05:38:23 +0300 Message-Id: <20210827023829.5871-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 0/6] libcamera: Drop emitter object pointer from signal arguments 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Hello, Many signals used in internal and public APIs carry the emitter pointer as a signal argument. This was done to allow slots connected to multiple signal instances to differentiate between emitters. While starting from a good intention of facilitating the implementation of slots, it turned out to be a bad API design as the signal isn't meant to know what it will be connected to, and thus shouldn't carry parameters that are solely meant to support a use case specific to the connected slot. This series fixes the issue. It starts with four patches that rework the BoundMethod and Signal implementation. Patch 1/6 is a drive-by fix that uses a simpler and less costly signal disconnection function when applicable. Patches 2/6 and 3/6 then simplify the BoundMethod implementation by removing two template specializations that turned out to be replaceable by simpler options. Patch 4/6 adds support for connecting signals to functors (and in particular to lambda functions), which is needed to address the problem at hand. Patch 5/6 reworks the implementation of some slots to avoid using the emitter pointer argument when the same object is available through a class member. Patch 6/6 finally drops the emitter pointer from signals, replacing the only case where the pointer is actually needed with a lambda wrapper. Laurent Pinchart (6): libcamera: Use simpler Signal::disconnect() function libcamera: base: bound_method: Remove BoundMethodMember specialization libcamera: base: bound_method: Remove BoundMethodArgs specialization libcamera: base: signal: Support connecting signals to functors libcamera: Don't use emitter object pointer argument to slot libcamera: Drop emitter object pointer from signal arguments Documentation/Doxyfile.in | 1 + include/libcamera/base/bound_method.h | 111 ++++++++---------- include/libcamera/base/event_notifier.h | 2 +- include/libcamera/base/signal.h | 19 +++ include/libcamera/base/thread.h | 2 +- include/libcamera/base/timer.h | 2 +- include/libcamera/camera.h | 2 +- .../internal/device_enumerator_udev.h | 2 +- .../libcamera/internal/ipc_pipe_unixsocket.h | 2 +- include/libcamera/internal/ipc_unixsocket.h | 4 +- include/libcamera/internal/media_device.h | 2 +- include/libcamera/internal/process.h | 4 +- include/libcamera/internal/v4l2_device.h | 2 +- include/libcamera/internal/v4l2_videodevice.h | 2 +- src/lc-compliance/simple_capture.cpp | 2 +- src/libcamera/base/event_dispatcher_poll.cpp | 4 +- src/libcamera/base/signal.cpp | 24 ++++ src/libcamera/base/thread.cpp | 2 +- src/libcamera/camera.cpp | 2 +- src/libcamera/camera_manager.cpp | 2 +- src/libcamera/device_enumerator.cpp | 2 +- src/libcamera/device_enumerator_udev.cpp | 2 +- src/libcamera/ipc_pipe_unixsocket.cpp | 4 +- src/libcamera/ipc_unixsocket.cpp | 4 +- src/libcamera/pipeline_handler.cpp | 2 +- src/libcamera/process.cpp | 4 +- src/libcamera/v4l2_device.cpp | 3 +- src/libcamera/v4l2_videodevice.cpp | 3 +- src/qcam/main_window.cpp | 4 +- test/camera/camera_reconfigure.cpp | 2 +- test/event-thread.cpp | 4 +- test/event.cpp | 17 ++- test/ipa/ipa_interface_test.cpp | 4 +- test/ipc/unixsocket.cpp | 8 +- test/ipc/unixsocket_ipc.cpp | 4 +- test/log/log_process.cpp | 3 +- test/process/process_test.cpp | 3 +- test/signal.cpp | 39 ++++++ test/timer-thread.cpp | 2 +- test/timer.cpp | 2 +- .../module_ipa_proxy_worker.cpp.tmpl | 4 +- 41 files changed, 192 insertions(+), 121 deletions(-)