What's the best way how to schedule a certain procedure to happen in a certain period within an app which use CommonC++ threads? Say, I have to postpone some task which then will access some methods of a class derived from Thread. Now I see only that signals aren't very multiplatform.
Thanks for any help.
Dimitri
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Common C++ does make use of and provide an implimentation for Suspend and Resume. There is also a generic "timer" capability in a Common C++ thread, but the actual capability varies by implimentation. I want to see about creating a more consistent and portable replacement for this...
David
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ok, thank you David. I think I will answer myself.
In my app I have conception of Task that have fulfill() method which returns success/failure. In case of failure I would like to repeat Task::fulfill() in a while (depending on a particular Task). I'm getting Task*'s from a separate thread (class derived from Thread) by means of a method gettask() which finally waits at Event object as Run() of this thread puts Task*'s in a queue and signals the Event. So the idea how to repeat a task in some period is to supply the task back to this thread object and make use of Event timeout for delaying tasks from immediate return by gettask() to the main app thread. This way I can solve lack of portable timers in CommonC++, but only because I don't need any particular time schedule in my app.
Hopefully this could give some ideas.
Dimitri
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
What's the best way how to schedule a certain procedure to happen in a certain period within an app which use CommonC++ threads? Say, I have to postpone some task which then will access some methods of a class derived from Thread. Now I see only that signals aren't very multiplatform.
Thanks for any help.
Dimitri
Common C++ does make use of and provide an implimentation for Suspend and Resume. There is also a generic "timer" capability in a Common C++ thread, but the actual capability varies by implimentation. I want to see about creating a more consistent and portable replacement for this...
David
Ok, thank you David. I think I will answer myself.
In my app I have conception of Task that have fulfill() method which returns success/failure. In case of failure I would like to repeat Task::fulfill() in a while (depending on a particular Task). I'm getting Task*'s from a separate thread (class derived from Thread) by means of a method gettask() which finally waits at Event object as Run() of this thread puts Task*'s in a queue and signals the Event. So the idea how to repeat a task in some period is to supply the task back to this thread object and make use of Event timeout for delaying tasks from immediate return by gettask() to the main app thread. This way I can solve lack of portable timers in CommonC++, but only because I don't need any particular time schedule in my app.
Hopefully this could give some ideas.
Dimitri