I apologize for the length of this problem, but I thought it was important to include sufficient details, given that I was looking for a suitable approach to my problem, and not just suggesting a code!
general description
I am working on a project that requires tasks to be โscheduledโ at some relative recurring interval.
These intervals refer to some internal time, which is represented as an integer that increases during program execution (which is not equal to real time). Each time this happens, the schedule will be interogated to check for any tasks that must be performed at this time interval.
If the task is being executed, it should be reconfigured to restart at a position relative to the current time (for example, 5 time stamps). This relative position is simply stored as an integer property of the Task object.
Problem:
I'm struggling a bit to decide how to structure it, partly because it's a bit of a complex set of search queries to search.
Be that as it may, I think that every time the timer increases, I need:
- Performing tasks at position "0" in the schedule
- Re-add these tasks to the schedule again in their relative position (for example, a task repeating every 5 steps will be returned to position 5)
- Each group of tasks in the schedule will have its own "time to completion", reduced (for example, the task in position 1 will move to position 0)
Assumption:
There are several suggestions that may limit the possible solutions that I can use:
- The interval should be relative, not a specific time, and is defined as an integer number of steps from the current time
- These intervals can take any integer value, for example. not limited.
- Several tasks can be scheduled for the same time, but their order of execution is not important.
- All execution should remain in one thread - multithreaded solutions are not suitable due to other restrictions
The main questions that I have are:
How can I design this schedule to work efficiently? What types of data / collections can be useful?
Is there any other structure / approach I should consider?
Am I wrong to reject planning frameworks (like quartz) that seem to work more in the "real" time domain, rather than the "unreal" time domain?
Thanks so much for any possible help. Please do not hesitate to comment on additional information, if necessary, I will edit where necessary!
java design algorithm scheduling
obfuscation
source share