开发者

Scheduling Task Based on Date time

开发者 https://www.devze.com 2023-03-14 23:02 出处:网络
I am working for private video network where I have to schedule the taskbased on following parameter.There is client Portal, Server and Gateway.

I am working for private video network where I have to schedule the task based on following parameter.There is client Portal, Server and Gateway. Through portal a user can request Streaming the video.

User can also Schedule Streaming for some future time.Each each task is having a task ID. Task is scheduled based on following date time par开发者_开发知识库ameter.

start time

end time

Repeat (every day,just once, a particular day)

start date

end date

Now at the gateway I need to add logic to Implement schedule task.

I am exploring Waitable Timer Objects and CreateWaitableTimerEe. I am bit confused whether it is possible to implement the feature using this.

I am using C++, MFC and can't use third party library.

I need Suggestion how to implement this.


There are dozens of ways to design this. It all depends on what you want to do and what the specific requirements are.

In a basic design I'd create an additional field called "next run time" which will be calculated by using start time, frequency and previous (if any) end time. Then I'd dump all the tasks in a queue sorted using this field.

The main scheduling will pick up the first queue item and create a suspended thread for that specific task. Now just calculate the time difference to the first item's 'next run time' and sleep for that time period. When you wake up just resume the thread and pick the next queue item and repeat.


I would just create a timer thread callback loop that checks the time every minute and executes your task on the specified schedule.

0

精彩评论

暂无评论...
验证码 换一张
取 消