From patchwork Mon Aug 12 12:46:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1778 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 DE36560E38 for ; Mon, 12 Aug 2019 14:46:48 +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 3B3F6327 for ; Mon, 12 Aug 2019 14:46:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1565614008; bh=XIA9IytBAHbQT12qkXQG/uIwm8noBuG9VaYc5NCjocs=; h=From:To:Subject:Date:From; b=uNEABFropwg1MN40Jt9BDhcUQGB/pMv/ru8EYSW4uPYt/GqWgVT0sya2eKG77B5CP l1iejxj37warJvZZNAdg4k5uk7UzHmq1paNfrTTG+h3FaaD5JF2uHaXcImSGqxge2j jfSNPzBXIb5VYr4zUUEnpdbpZRoxLIp/mwe75P/w= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 12 Aug 2019 15:46:24 +0300 Message-Id: <20190812124642.24287-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 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: Mon, 12 Aug 2019 12:46:49 -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. 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 | 32 ++++- 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 | 120 +++++++++++++++--- 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, 948 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 Reviewed-by: Jacopo Mondi