[{"id":3359,"web_url":"https://patchwork.libcamera.org/comment/3359/","msgid":"<20200107185917.GD533370@oden.dyn.berto.se>","date":"2020-01-07T18:59:17","subject":"Re: [libcamera-devel] [PATCH 02/14] libcamera: object: Use\n\tactivate() in invokeMethod()","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your work.\n\nOn 2020-01-04 07:09:35 +0200, Laurent Pinchart wrote:\n> The Object::invokeMethod() implementation duplicates pack creation code\n> from BoundMemberMethod::activate(). Call activate() instead of\n> activatePack() to share code.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  include/libcamera/bound_method.h | 15 ++++++++++-----\n>  include/libcamera/object.h       |  7 ++-----\n>  2 files changed, 12 insertions(+), 10 deletions(-)\n> \n> diff --git a/include/libcamera/bound_method.h b/include/libcamera/bound_method.h\n> index b841a2aed147..5743cacf5388 100644\n> --- a/include/libcamera/bound_method.h\n> +++ b/include/libcamera/bound_method.h\n> @@ -37,10 +37,11 @@ public:\n>  \tObject *object() const { return object_; }\n>  \tConnectionType connectionType() const { return connectionType_; }\n>  \n> -\tvoid activatePack(void *pack, bool deleteMethod);\n>  \tvirtual void invokePack(void *pack) = 0;\n>  \n>  protected:\n> +\tvoid activatePack(void *pack, bool deleteMethod);\n> +\n>  \tvoid *obj_;\n>  \tObject *object_;\n>  \tConnectionType connectionType_;\n> @@ -88,7 +89,7 @@ public:\n>  \t\tinvokePack(pack, typename generator<sizeof...(Args)>::type());\n>  \t}\n>  \n> -\tvirtual void activate(Args... args) = 0;\n> +\tvirtual void activate(Args... args, bool deleteMethod = false) = 0;\n>  \tvirtual void invoke(Args... args) = 0;\n>  };\n>  \n> @@ -106,10 +107,10 @@ public:\n>  \n>  \tbool match(void (T::*func)(Args...)) const { return func == func_; }\n>  \n> -\tvoid activate(Args... args)\n> +\tvoid activate(Args... args, bool deleteMethod = false)\n>  \t{\n>  \t\tif (this->object_)\n> -\t\t\tBoundMethodBase::activatePack(new PackType{ args... }, false);\n> +\t\t\tBoundMethodBase::activatePack(new PackType{ args... }, deleteMethod);\n>  \t\telse\n>  \t\t\t(static_cast<T *>(this->obj_)->*func_)(args...);\n>  \t}\n> @@ -135,7 +136,11 @@ public:\n>  \n>  \tbool match(void (*func)(Args...)) const { return func == func_; }\n>  \n> -\tvoid activate(Args... args) { (*func_)(args...); }\n> +\tvoid activate(Args... args, bool deleteMethod = false)\n> +\t{\n> +\t\t(*func_)(args...);\n> +\t}\n> +\n>  \tvoid invoke(Args...) {}\n>  \n>  private:\n> diff --git a/include/libcamera/object.h b/include/libcamera/object.h\n> index 21b70460b516..c45165dec8ef 100644\n> --- a/include/libcamera/object.h\n> +++ b/include/libcamera/object.h\n> @@ -35,11 +35,8 @@ public:\n>  \t\t\t  Args... args)\n>  \t{\n>  \t\tT *obj = static_cast<T *>(this);\n> -\t\tBoundMethodBase *method =\n> -\t\t\tnew BoundMemberMethod<T, FuncArgs...>(obj, this, func, type);\n> -\t\tvoid *pack = new typename BoundMemberMethod<T, FuncArgs...>::PackType{ args... };\n> -\n> -\t\tmethod->activatePack(pack, true);\n> +\t\tauto *method = new BoundMemberMethod<T, FuncArgs...>(obj, this, func, type);\n> +\t\tmethod->activate(args..., true);\n>  \t}\n>  \n>  \tThread *thread() const { return thread_; }\n> -- \n> Regards,\n> \n> Laurent Pinchart\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lj1-x243.google.com (mail-lj1-x243.google.com\n\t[IPv6:2a00:1450:4864:20::243])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C98DA6063B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  7 Jan 2020 19:59:19 +0100 (CET)","by mail-lj1-x243.google.com with SMTP id j1so703145lja.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 07 Jan 2020 10:59:19 -0800 (PST)","from localhost (h-93-159.A463.priv.bahnhof.se. [46.59.93.159])\n\tby smtp.gmail.com with ESMTPSA id\n\ts13sm212147lje.35.2020.01.07.10.59.18\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 07 Jan 2020 10:59:18 -0800 (PST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=tilCUYi/ChtPifMBrjzIFVml58pk/wbAsMC0kbihA5M=;\n\tb=YocXe0qwowaKUCKHqw6/VGDV6VLyJNCdmSCSHtlCVhsf2NV31Too3HRKeiRmtzC8UB\n\tU+lNb7CYHNOll5P3sAHHF+86MabFh9vDW2IDzQjsL+CwjDcXOxG9q4DzxfVB7501vTzW\n\t0qPllFQAvW70tUJblhJa+KrcmunVkDKbBJRDEnERsbVhI6oBULxt7PYt3FYNBRfUBbZX\n\t/N8WhpQVBsGUg7hgT4E1m+wq/Kij59rs970cZ3Oyup4B0DXUn9JbXxGIEJ+Vq3Ws6Lsv\n\tnFD5dpvsNBnWgbkpk5WI2NyO3DamM2f4NkUmUGPBhLBSXcHdw3UXym3W8QUOgEXitT4k\n\tJxHg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=tilCUYi/ChtPifMBrjzIFVml58pk/wbAsMC0kbihA5M=;\n\tb=Ql3C1FDNWCdp7OYf+Ywd+2nPFr0jMOXlR8RyMv3mBc+etbCIO3Faym6dasstTG6mTc\n\tC4KKjE4Yp8aeDWtXiRyHt069k+q+nPFnVRp9hudpe17+e7iJfuxaTeprMyvv0C3yQCfP\n\tVCxmX1x5Nue1a3V+g25hVEupHf+HqIw20w3kZ3hlLWLWd3DQI6X/TeAfMhR9eFWyKtVU\n\tx+H45ZjNR0ddtz9axYpUFUURLSq6lhsgBQwfMWvUcM79aaybnpaTKWo/Ut2xVkTqV0nH\n\tw93ugBagNt0YBfBX4kEMkIpoZkHxQ1xJlubL84pmJgsyaE0uWwkLe3vmLZuk+N8Vaw47\n\t8lFQ==","X-Gm-Message-State":"APjAAAX0OnBG5pBi2zZUEcauxmU1QHnTJpXOFvWhzWAZ2k8HIEHWFWVE\n\tERJuilKwY9KISOzRk5BOwLBRdXXE5Q6NLg==","X-Google-Smtp-Source":"APXvYqwSNFiDV+i/KShm+AdtrAZrX0ZBbLTrgGG6WYhEKjtvLAbY5sAxwfmrmAe8iWhjBcCk3SwKow==","X-Received":"by 2002:a2e:8152:: with SMTP id t18mr513785ljg.255.1578423559184;\n\tTue, 07 Jan 2020 10:59:19 -0800 (PST)","Date":"Tue, 7 Jan 2020 19:59:17 +0100","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200107185917.GD533370@oden.dyn.berto.se>","References":"<20200104050947.7673-1-laurent.pinchart@ideasonboard.com>\n\t<20200104050947.7673-3-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200104050947.7673-3-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 02/14] libcamera: object: Use\n\tactivate() in invokeMethod()","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Tue, 07 Jan 2020 18:59:19 -0000"}}]