Threading & job questions



  • Hello,

    Besides using ParallelFor() I have never had much to do with threading.

    On program startup, we check our web server for available updates of our plugin. At the moment, this is done in the main thread, hence blocking it and prolonging program startup time. Therefore, I want to move that into a separate thread. I looked into the SDK docs for inspiration, and found that Jobs might be what I need.

    Question 1: (solved already, my bad)
    Looking at the example for for FactorialJob (https://developers.maxon.net/docs/Cinema4DCPPSDK/html/page_maxonapi_threading_jobs.html#page_maxonapi_threading_jobs_job), I see that the constructor that takes the input data (maxon::UInt) must be marked with MAXON_IMPLICIT. This is the first thing not working for me:

    Screen Shot 2020-01-13 at 12.01.38.png

    I see MAXON_IMPLICIT is defined in apibase.h, but including the header does not change anything, the errors are still there.

    Question 2:
    In the documentation of JobCueueInterface, an example file called filterwhirl.cpp is mentioned, which I'd love to take a look at. Where can I find it? The article also mentions tutorials, which I could not find.

    Question 3:
    Our update check currently invokes a Python plugin for the actual HTTP request to our online REST API (called via CallCommand(), there are different reasons why we did it that way, it will have to remain this way for a while). Since in the Job Manual (https://developers.maxon.net/docs/Cinema4DCPPSDK/html/page_maxonapi_threading_jobs.html) it states explicitly: "Make sure that a job has no additional, hidden dependencies like for example executing parallelized code internally.", does this mean I cannot parallelize this at all?

    Seasoned programmer, but with greenhorn threading questions ;-)
    I'm hoping to get some answers that will get me started without investing too much time into this.

    Thank you in advance & best greetings from Berlin,
    Frank



  • well, as for Q1 you did write MAXON_IMPLICITE with an E at the end in your code, so the compiler doesn't know that...



  • Oh my god. the stupidest error.... 😵
    OK, question 1 solved already, thanks 😁



  • Hm, and it seems my assumption in Question 3 is true. The Python Plugin called via CallCommand() is not executed (call returns immediately with no results). I'll look for another solution then.

    Question 2 remains valid, though ;-)
    Example plugins that demonstrate the practical use of Jobs and Queues would be most welcome!

    Cheers,
    Frank



  • Hello,

    Q2 :
    filterwhirl.cpp is a internal file you don't have access to it. And we don't have tutorials. (this comment will be removed to avoid confusion)

    Q3 :
    CallCommand should be use on the main thread, that's maybe why it's not working, you can use ExecuteOnMainThread in your job.

    Cheers,
    Manuel