Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Prevent changing the activity from a component's own thread #171

Merged

Conversation

meyerj
Copy link
Member

@meyerj meyerj commented Sep 5, 2016

This patch partially solves issue #141. It is not possible to change the activity of a component from within the component's thread because it would have to destroy itself afterwards. RTT::TaskContext::setActivity() logs an error and returns false in this case. RTT::TaskContext::forceActivity() logs a fatal error.

The debug log output during thread termination has been moved from the thread destructor to the terminate() method to fix logging during the destruction of RTT::Activity (see also 58cb4bb).

@meyerj
Copy link
Member Author

meyerj commented Sep 5, 2016

This patch breaks some tests that call setActivity() on a component which returns MainThread::Instance() from getActivity()->thread(). See #170 for a related issue that is also caused by not knowing which thread will execute an activity in some cases. I am currently working on a patch based on the idea that RTT::base::ActivityInterface::thread() should return null in those cases.

@meyerj meyerj changed the title Prevent changing the activity calls from a component's own thread Prevent changing the activity from a component's own thread Sep 5, 2016
…olchain#141)

This patch partially solves issue orocos-toolchain#141. It is not possible to change the activity of a component
from within the component's thread because it would have to destroy itself afterwards.
RTT::TaskContext::setActivity() logs an error and returns false in this case.

The debug log output during thread termination has been moved from the thread destructor to the
terminate() method to fix logging during the destruction of RTT::Activity (see also 58cb4bb).

Signed-off-by: Johannes Meyer <johannes@intermodalics.eu>
This is a workaround for the fact that getActivity()->thread() returns the main thread in some
cases and therefore it would not be possible to change the activity from the main thread while
it is active, e.g. during unit tests.

Signed-off-by: Johannes Meyer <johannes@intermodalics.eu>
@meyerj meyerj force-pushed the fix/check-for-isself-in-setactivity branch from 2f70acd to ddf343f Compare September 6, 2016 09:52
rtt/TaskContext.cpp Outdated Show resolved Hide resolved
@meyerj meyerj merged commit 1e7a2ce into orocos-toolchain:master Apr 16, 2019
@meyerj meyerj deleted the fix/check-for-isself-in-setactivity branch April 16, 2019 13:48
meyerj added a commit that referenced this pull request Apr 16, 2019
…ty into toolchain-2.9.1

Prevent changing the activity from a component's own thread
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants