GithubHelp home page GithubHelp logo

Comments (3)

meyerj avatar meyerj commented on May 27, 2024

I cannot reproduce this issue with 2.9 and the gnulinux target.

With 58cb4bb it should not be possible to destroy an Activity instance before the underlying thread is terminated. Before 2.9 the thread function was implemented in the RTT::os::Thread class and it was only the ~Thread destructor that joined after the Activity subclass has already been destroyed.

I see that there might be issues if setActivity() would be called from the thread to be destroyed itself. Not sure if this is properly caught. But that does not seem to be the case in your example. Which thread executes the stop, configure, start operations? The TaskBrowser? Or a script running in the scripting service of exactly the component in question?

If there is no need to recreate the activity because only the periodicity changed, prefer setPeriod() instead, which works even while the activity is running.

from rtt.

pdima avatar pdima commented on May 27, 2024

I found task.stop(); task.configure(); task.start(); sequence is called in client thread as OwnThread operation. It works fine when ClientThread used.

Is it acceptable to change activity during configureHook? I tried to apply priority and scheduler from properties/configuration not available at construction time.

from rtt.

meyerj avatar meyerj commented on May 27, 2024

Is it acceptable to change activity during configureHook? I tried to apply priority and scheduler from properties/configuration not available at construction time.

In general it is okay to set the component's activity in the configureHook(), but only if it is called from an external thread, not from the thread running the component itself (like in an OwnThread operation). Usually this external thread is the main thread and configure() is called during deployment.

You can modify all relevant properties of an existing activity in configureHook(), while the thread is running without having to destroy the activity:

RTT::TaskContext *tc = this;
tc->setPeriod(new_period);
RTT::os::ThreadInterface *thread = tc->getActivity()->thread();
if (thread) {
    thread->setScheduler(sched_type);
    thread->setPriority(priority);
}

Note that not every activity has its own thread and a thread might be reused by multiple activities for certain activity types. At the moment getActivity()->thread() always returns the main thread in case there is no thread associated to the activity, but I am going to change that for 2.9. For the standard Activity there are no issues and the code snippet above should just do what you would expect.

from rtt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.