Coder Social home page Coder Social logo

Comments (7)

samtertzakian avatar samtertzakian commented on May 16, 2024 1

The pending PR has a fix for this issue: #178

from dmf.

samtertzakian avatar samtertzakian commented on May 16, 2024 1

Resolved by Release v1.1.98. Please use new DMF_ScheduledTask_ExecuteNowDeferredEx() Method. It honors the return value correctly.

from dmf.

samtertzakian avatar samtertzakian commented on May 16, 2024

Sorry for delayed response.

See resolution below...

from dmf.

samtertzakian avatar samtertzakian commented on May 16, 2024

Ok, I see what the issue is:

You need to use:

dmfSchedulerCfg.ExecuteWhen = ScheduledTask_ExecuteWhen_PrepareHardware;
or
dmfSchedulerCfg.ExecuteWhen = ScheduledTask_ExecuteWhen_D0Entry;

When you do so you do not use:

DMF_ScheduledTask_ExecuteNowDeferred() or DMF_ScheduledTask_ExecuteNow()
Instead the scheduled task will be automatically started when PrepareHardware or D0Entry happen.

In this case, the scheduled task callback will be called automatically and repeatedly as you expected.

You used:

dmfSchedulerCfg.ExecuteWhen = ScheduledTask_ExecuteWhen_Other;

In this case you also used: DMF_ScheduledTask_ExecuteNowDeferred() or DMF_ScheduledTask_ExecuteNow()

But when you do so using the Method, the automatic retry does not happen (by design).

This is not intuitive and can be considered to be a bug.
At the minimum, the documentation and comments in the code will be updated to reflect this behavior.
But, if possible, we will see if we can update the code so that "Other" mode allows periodic call of Scheduled Task so that it works as one would expect.

Thank you for your feedback.

Please contact [email protected] for faster responses.

from dmf.

nefarius avatar nefarius commented on May 16, 2024

Thank you very much for the insights, I will test with ScheduledTask_ExecuteWhen_D0Entry then, should be alright.

Appreciate the addition to documentation!

One more question though; am I then by design allowed to still call DMF_ScheduledTask_ExecuteNowDeferred() "in between" when I need to not await the specified timeout value? I'd like to utilize it that way to send a packet to my device ASAP when necessary and sticking to just using the scheduler callback would allow me to not care about synchronization as the only sending code would remain in that callback.

Cheers!

from dmf.

samtertzakian avatar samtertzakian commented on May 16, 2024

Yes, you instantiate using ScheduledTask_ExecuteWhen_D0Entry. Then, you can use DMF_ScheduledTask_ExecuteNow() to cause the same callback to be immediately called. In this case, however, you may need to acquire and release a lock in the callback to make sure that the deferred callback using timer does not race with your immediate execution. In fact, there is a comment in the code that explains that. If I recall, we specifically added DMF_ScheduledTask_ExecuteNow() for the exact purpose you describe.

Having said all that, I will update the documentation to explain all this (and possibly add a Method to do what you originally intended). I will keep this issue open until the documentation is updated. Let me know if you have any other questions. Thank you for the feedback.

from dmf.

nefarius avatar nefarius commented on May 16, 2024

Yes, you instantiate using ScheduledTask_ExecuteWhen_D0Entry. Then, you can use DMF_ScheduledTask_ExecuteNow() to cause the same callback to be immediately called. In this case, however, you may need to acquire and release a lock in the callback to make sure that the deferred callback using timer does not race with your immediate execution. In fact, there is a comment in the code that explains that. If I recall, we specifically added DMF_ScheduledTask_ExecuteNow() for the exact purpose you describe.

It works now exactly as I need it with these adjustments, thanks! Also introduced a lock just to be safe.

from dmf.

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.