Skip to content

Commit

Permalink
operations: improve OperationCallerInterface::isSend() for master-sla…
Browse files Browse the repository at this point in the history
…ve 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 <peter@intermodalics.eu>

This is the 2nd commit message:

operations: fixup isSend() logic to also work if no caller is known.

Signed-off-by: Peter Soetens <peter@intermodalics.eu>

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 <peter@intermodalics.eu>
  • Loading branch information
psoetens authored and meyerj committed Dec 21, 2015
1 parent e7ede9f commit f5e1d78
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions rtt/base/OperationCallerInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
4 changes: 3 additions & 1 deletion rtt/base/OperationCallerInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions rtt/internal/LocalOperationCaller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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." <<endlog();
log(Error) << "Use this->engine() in a component or GlobalEngine::Instance() in a non-component function. Returning a CollectFailure." <<endlog();
assert( false && "You forgot to use setCaller(). See Orocos LOG messages for explanation.");
return false;
}
return true;
Expand Down

0 comments on commit f5e1d78

Please # to comment.