diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2019-10-28 05:31:12 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2019-10-29 16:41:54 +0200 |
commit | 3d75cc1bd209cf1de909ce5c8c9cec16789708f6 (patch) | |
tree | 5e23464cd2bbbefaaa38cbf900c809d81754ffa8 /src/libcamera/bound_method.cpp | |
parent | df2518b2a3451ad73ebddce056b68edb98ab0f7c (diff) |
libcamera: bound_method: Support connection types
Support all connection types in the BoundMethodBase::activePack()
method. To support this, add a semaphore to the InvokeMessage to signal
delivery.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'src/libcamera/bound_method.cpp')
-rw-r--r-- | src/libcamera/bound_method.cpp | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/libcamera/bound_method.cpp b/src/libcamera/bound_method.cpp index ab6ecd94..60071736 100644 --- a/src/libcamera/bound_method.cpp +++ b/src/libcamera/bound_method.cpp @@ -8,6 +8,7 @@ #include <libcamera/bound_method.h> #include "message.h" +#include "semaphore.h" #include "thread.h" #include "utils.h" @@ -49,12 +50,37 @@ namespace libcamera { void BoundMethodBase::activatePack(void *pack) { - if (Thread::current() == object_->thread()) { + ConnectionType type = connectionType_; + if (type == ConnectionTypeAuto) { + if (Thread::current() == object_->thread()) + type = ConnectionTypeDirect; + else + type = ConnectionTypeQueued; + } + + switch (type) { + case ConnectionTypeDirect: + default: invokePack(pack); - } else { + break; + + case ConnectionTypeQueued: { std::unique_ptr<Message> msg = utils::make_unique<InvokeMessage>(this, pack); object_->postMessage(std::move(msg)); + break; + } + + case ConnectionTypeBlocking: { + Semaphore semaphore; + + std::unique_ptr<Message> msg = + utils::make_unique<InvokeMessage>(this, pack, &semaphore); + object_->postMessage(std::move(msg)); + + semaphore.acquire(); + break; + } } } |