From patchwork Sat Aug 17 15:20:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1818 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 116C6600F9 for ; Sat, 17 Aug 2019 17:21:13 +0200 (CEST) Received: from pendragon.bb.dnainternet.fi (dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9A7BD556 for ; Sat, 17 Aug 2019 17:21:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1566055272; bh=iEwTALH8CuFS+klUXP7eyEBXTZRrT7aZN6ZduZ2/0uY=; h=From:To:Subject:Date:From; b=hb2vKCRRtZb/VfvP7p9dc+vGLI52rSb5CkZXZMHLwDyNZn7O6oEKvZ1bF/QDA01fy 2OP8BqMgGqvoU2syE9P3VpEPIvzFRcP5XWNROWznjvSWmwFCOWtXFl2vlWSGe4+jxa 8h1CEygY7oDjUoJsWrHy8E+VA86fAuhJda1Kd8Js= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sat, 17 Aug 2019 18:20:46 +0300 Message-Id: <20190817152104.10834-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 00/18] Object & Thread enhancements X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Aug 2019 15:21:13 -0000 Hello everybody, This patch series extends the Object and Thread implementations in libcamera to improve thread affinity handling. This first patch is a simple cleanup. Object instances are associated with a thread, and the thread affinity can be changed with Object::moveToThread(). This moves pending messages for the object to the message queue of the new thread. Patch 02/18 fixes a bug in the implementation that forgot to wake up the event loop of the new thread, and patch 03/18 fixes a bug that prevented dispatching message to the main thread. The next three patches split the slot-related classes from signal.h (04/18), decouple them from the signal implementation (05/18) and use them to add a new asynchronous method invocation mechanism for the Object class (06/18). Patch 07/18 then adds a message to notify Object instances of thread move. The next two patches are new tests for those APIs. Patches 10/18 to 12/18 bind CameraManager, EventNotifier and Timer instances to threads by inheriting from the Object class. The EventNotifier and Timer classes now support being moved to a different thread with proper operation with the new thread's event loop. The next two patches add new tests for those operations. Patch 15/18 adds a parent-child hierarchy in the Object class, to simplify moving objects to threads. Patch 16/18 supports this by adding a parent argument to the constructor of various classes. Patch 17/18 extends the object test to cover the parent-child relationships, and patch 18/18 shows how they can simplify code. Please see individual patches for changelogs. Laurent Pinchart (18): libcamera: object: Make message() method protected libcamera: thread: Wake up target thread when moving objects libcamera: thread: Support dispatching messages to main thread libcamera: signal: Split Slot implementation to reusable classes libcamera: bound_method: Decouple from Signal implementation libcamera: object: Add an asynchronous method invocation method libcamera: object: Notify objects of thread move test: Add Object::invokeMethod() test test: Add Object class thread affinity test libcamera: camera_manager: Bind CameraManager to threads libcamera: event_notifier: Bind event notifiers to threads libcamera: timer: Bind timers to threads test: Add EventNotifier thread move test test: Add Timer thread move test libcamera: object: Create parent-child relationships libcamera: Add parent argument to constructors of Object-derived classes test: object: Extend object test to verify parent-child relationships test: Simplify tests with parent-child relationships Documentation/Doxyfile.in | 10 +- include/libcamera/bound_method.h | 130 +++++++++++++++++++ include/libcamera/camera_manager.h | 4 +- include/libcamera/event_notifier.h | 10 +- include/libcamera/meson.build | 1 + include/libcamera/object.h | 31 ++++- include/libcamera/signal.h | 151 +++------------------- include/libcamera/timer.h | 13 +- src/libcamera/bound_method.cpp | 27 ++++ src/libcamera/camera_manager.cpp | 4 +- src/libcamera/event_dispatcher_poll.cpp | 3 + src/libcamera/event_notifier.cpp | 22 +++- src/libcamera/include/message.h | 22 ++-- src/libcamera/include/thread.h | 5 +- src/libcamera/meson.build | 1 + src/libcamera/message.cpp | 50 ++++++-- src/libcamera/object.cpp | 113 ++++++++++++++--- src/libcamera/signal.cpp | 23 ---- src/libcamera/thread.cpp | 26 +++- src/libcamera/timer.cpp | 33 ++++- test/event-thread.cpp | 106 ++++++++++++++++ test/meson.build | 4 + test/object-invoke.cpp | 137 ++++++++++++++++++++ test/object.cpp | 158 ++++++++++++++++++++++++ test/timer-thread.cpp | 72 +++++++++++ 25 files changed, 940 insertions(+), 216 deletions(-) create mode 100644 include/libcamera/bound_method.h create mode 100644 src/libcamera/bound_method.cpp create mode 100644 test/event-thread.cpp create mode 100644 test/object-invoke.cpp create mode 100644 test/object.cpp create mode 100644 test/timer-thread.cpp