From f5e1d78ed899b09dbdd933c2072ca25f1fd209d8 Mon Sep 17 00:00:00 2001 From: Peter Soetens Date: Wed, 29 Apr 2015 22:27:47 +0200 Subject: [PATCH] operations: improve OperationCallerInterface::isSend() for master-slave calls This is a combination of 3 commits. The first commit's message is: operations: assert if the caller is not set and improve isSend isSend now only returns true if the thread differs, not just the EE. So that it also does not send in case of a master-slave call. Signed-off-by: Peter Soetens This is the 2nd commit message: operations: fixup isSend() logic to also work if no caller is known. Signed-off-by: Peter Soetens This is the 3rd commit message: operations: improved isSend implementation that does not need caller As suggested by @meyerj, we can use isSelf() instead of comparing threads. Signed-off-by: Peter Soetens --- rtt/base/OperationCallerInterface.cpp | 8 ++++++++ rtt/base/OperationCallerInterface.hpp | 4 +++- rtt/internal/LocalOperationCaller.hpp | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/rtt/base/OperationCallerInterface.cpp b/rtt/base/OperationCallerInterface.cpp index 8094dd5ad..4d689d5d6 100644 --- a/rtt/base/OperationCallerInterface.cpp +++ b/rtt/base/OperationCallerInterface.cpp @@ -31,6 +31,14 @@ bool OperationCallerInterface::setThread(ExecutionThread et, ExecutionEngine* ex return true; } +bool OperationCallerInterface::isSend() +{ + if ( met == ClientThread ) return false; + // OwnThread case: + if ( myengine->getActivity()->thread()->isSelf() ) return false; + return true; // all other OwnThread cases +} + ExecutionEngine* OperationCallerInterface::getMessageProcessor() const { ExecutionEngine* ret = (met == OwnThread ? myengine : GlobalEngine::Instance()); diff --git a/rtt/base/OperationCallerInterface.hpp b/rtt/base/OperationCallerInterface.hpp index 2252fd5db..e3176d878 100644 --- a/rtt/base/OperationCallerInterface.hpp +++ b/rtt/base/OperationCallerInterface.hpp @@ -75,8 +75,10 @@ namespace RTT /** * Helpful function to tell us if this operations is to be sent or not. + * Sending is only required if the operation is OwnThread *and* in a + * different thread than the caller. */ - bool isSend() { return met == OwnThread && myengine != caller; } + bool isSend(); ExecutionEngine* getMessageProcessor() const; diff --git a/rtt/internal/LocalOperationCaller.hpp b/rtt/internal/LocalOperationCaller.hpp index 33bdd6bb0..4f309b5cf 100644 --- a/rtt/internal/LocalOperationCaller.hpp +++ b/rtt/internal/LocalOperationCaller.hpp @@ -285,6 +285,7 @@ namespace RTT if (!this->caller) { log(Error) << "You're using call() an OwnThread operation or collect() on a sent operation without setting a caller in the OperationCaller. This often causes deadlocks." <engine() in a component or GlobalEngine::Instance() in a non-component function. Returning a CollectFailure." <