Issue with the task handle #36
Serotonindude
started this conversation in
General
Replies: 1 comment 1 reply
-
There are two reasons it's implemented this way:
Returning the address as suggested only provides benefit 1, but not 2, and will fail in a case like this: tid_1 = timer.at(1, handler);
// 1 milli passes and handler gets executed
tid_2 = timer.at(100, other_handler)
timer.cancel(tid_1); // ERROR - this might cancel other_handler since tid_1 == tid_2 is possible It's easy to see that tid_1 handler already finished and doesn't need to be canceled in this linear example, but it might not be so clear in more realistic use cases. If you could provide example code showing the error, maybe we can help diagnose the issue. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
we've encountered a problem with the task handle which is passed to the user when a task is started. Sometimes the Timer class just wouldn't remove the task on cancellation. It just didn't pass the test
in some cases. Of course we made sure our task handles were correct and not already cancelled etc. The automatic removing when the handler returns false worked fine, which does not do this test.
We've then removed the obscuring of the actual address of the internal task struct via its id from this test and also from the task_id method in a local copy of the header file:
This solved the problem. I know, it should actually work, as A ^ B ^ B = A but for whichever reason (compiler, pointer stuff, whatever...) it didn't...
So is there any deeper need for the address obscuring? If not, maybe it could be removed?
Kind regards,
Sero
Beta Was this translation helpful? Give feedback.
All reactions