CN108279971A - A kind of timing executes the method and device of task - Google Patents

A kind of timing executes the method and device of task Download PDF

Info

Publication number
CN108279971A
CN108279971A CN201810076694.5A CN201810076694A CN108279971A CN 108279971 A CN108279971 A CN 108279971A CN 201810076694 A CN201810076694 A CN 201810076694A CN 108279971 A CN108279971 A CN 108279971A
Authority
CN
China
Prior art keywords
task
timing
timed task
time
timed
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201810076694.5A
Other languages
Chinese (zh)
Inventor
王同庆
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Bank of China Ltd
Original Assignee
Bank of China Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Bank of China Ltd filed Critical Bank of China Ltd
Priority to CN201810076694.5A priority Critical patent/CN108279971A/en
Publication of CN108279971A publication Critical patent/CN108279971A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues

Abstract

The present invention provides the method and devices that a kind of timing executes task, and the method includes obtaining preset heartbeat control frequency and preset task execution condition;Wherein, the task execution condition includes the timing information executed needed for timed task;Based on scheduled reference instant, timing is carried out using heartbeat control frequency, obtains clocking information;According to the clocking information and the timing information, whether judgement currently needs to start to execute the timed task;If so, starting to execute the timed task.It can be seen that, the invention discloses the implementations that a kind of timing based on heartbeat control executes task, utilize application scheme, can be higher precision grade (such as ms ranks) by the way that heartbeat is controlled set of frequency, accordingly to control the execution precision of timed task in higher precision grade (such as ms ranks), to apply the present invention program, the execution accuracy of timed task can be effectively promoted.

Description

A kind of timing executes the method and device of task
Technical field
The invention belongs to the method and devices that task scheduling technique field more particularly to a kind of timing execute task.
Background technology
Timing executes task, refers to being based on given point in time, given interval or given execution number are automatically Execution task.
In the prior art, timing execute task when, usually by read current time, and by the current time of reading with The mode that time point corresponding to the time interval at given time point/given is compared, to realize timing execution task.Tool Body, for example, reading current time from the time module of time server or system, and reach given task in current time Start to execute task dispatching when time point corresponding to the given time interval of start time point/reach.
However, when executing task using aforesaid way timing, the accuracy of task execution is relatively low, is generally only capable of being accurate to Second rank, can not support the execution accuracy of the higher levels such as millisecond.
Invention content
In view of this, the purpose of the present invention is to provide the method and devices that a kind of timing executes task, it is intended to solve existing There is the above problem existing for technology, promotes the execution accuracy of timed task.
For this purpose, the present invention is disclosed directly below technical solution:
A kind of method that timing executes task, including:
Obtain preset heartbeat control frequency and preset task execution condition;Wherein, the task is held Row condition includes the timing information executed needed for timed task;
Based on scheduled reference instant, timing is carried out using heartbeat control frequency, obtains clocking information;
According to the clocking information and the timing information, whether judgement currently needs to start to execute the timed task;
If so, starting to execute the timed task.
The above method, it is preferred that the preset task execution condition of acquisition, including:
Obtain the task execution condition or expansible for the regular expression form being generated in advance based on Target Setting Mode The task execution condition of mark language XML linguistic form.
The above method, it is preferred that the Target Setting Mode is the first Setting pattern, the second Setting pattern and third setting Corresponding modes in pattern;Wherein:
First Setting pattern is used to indicate executes multiple timing task at predetermined intervals in the scheduled time; The corresponding timing parameters of first Setting pattern include:Time started, end time repeat number and repeat Time interval;
Second Setting pattern is used to indicate each time point in multiple predetermined point of time within a predetermined period of time Execute multiple timing task;The corresponding timing parameters of second Setting pattern include:Execute period, predetermined point of time, again The time interval for executing number again and repeating;
The third Setting pattern is used to indicate the schedule based on calendar and executes timed task;Mould is arranged in the third The corresponding timing parameters of formula include:Second, minute, hour, which day in one month, month, which day in one week, the time.
The above method, it is preferred that it is described to be based on scheduled reference instant, timing is carried out using heartbeat control frequency, Including:
When executing multiple timing task, the moment on the basis of the finish time of last timed task starts with institute It is the execution progress timing when previous timed task to state heartbeat control frequency, obtains clocking information;
Correspondingly, described according to the clocking information and the timing information, whether judgement currently needs to start to execute The timed task, including:
Between judging whether timing duration that the clocking information includes reaches the time included in the timing information Every, if reaching, triggering the step of starting to execute the timed task.
The above method, it is preferred that the execution timed task, including:
The timed task is executed based on the thread pool being pre-created;
Wherein, described that the timed task is executed based on the thread pool being pre-created, including:
When the quantity for the timed task for needing to execute is multiple, based on multiple threads in the thread pool to multiple institutes Timed task is stated to be executed parallel.
The above method, it is preferred that the method further includes:
The implementation procedure of the timed task is monitored, and monitored results are fed back into maintenance personnel.
The above method, it is preferred that the method further includes:
Persistence processing is carried out to the timed task, so that when the timed task interrupts, it can be from persistence The persistence information point of processing gained re-executes the timed task.
A kind of timing executes the device of task, including:
Acquiring unit, for obtaining preset heartbeat control frequency and preset task execution condition;Its In, the task execution condition includes the timing information executed needed for timed task;
Timing unit carries out timing using heartbeat control frequency, obtains timing for being based on scheduled reference instant Information;
Judging unit, for according to the clocking information and the timing information, whether judgement currently to need to start to execute The timed task;
Task executing units, for when the determination result is yes, starting to execute the timed task.
Above-mentioned apparatus, it is preferred that the acquiring unit obtains preset task execution condition and specifically includes:
Obtain the task execution condition or XML language of the regular expression form being generated in advance based on Target Setting Mode The task execution condition of form.
Above-mentioned apparatus, it is preferred that the target that the acquiring unit is based on when obtaining the task execution condition Setting pattern is the corresponding modes in the first Setting pattern, the second Setting pattern and third Setting pattern;Wherein:
First Setting pattern is used to indicate executes multiple timing task at predetermined intervals in the scheduled time; The corresponding timing parameters of first Setting pattern include:Time started, end time repeat number and repeat Time interval;
Second Setting pattern is used to indicate each time point in multiple predetermined point of time within a predetermined period of time Execute multiple timing task;The corresponding timing parameters of second Setting pattern include:Execute period, predetermined point of time, again The time interval for executing number again and repeating;
The third Setting pattern is used to indicate the schedule based on calendar and executes timed task;Mould is arranged in the third The corresponding timing parameters of formula include:Second, minute, hour, which day in one month, month, which day in one week, the time.
Above-mentioned apparatus, it is preferred that the timing unit is specifically used for:
When executing multiple timing task, the moment on the basis of the finish time of last timed task starts with institute It is the execution progress timing when previous timed task to state heartbeat control frequency, obtains clocking information;
Correspondingly, the judging unit, is specifically used for:
Between judging whether timing duration that the clocking information includes reaches the time included in the timing information Every if reaching, triggering the task executing units and start to execute the timed task.
Above-mentioned apparatus, it is preferred that the task executing units are specifically used for:Institute is executed based on the thread pool being pre-created State timed task;
The task executing units execute the timed task based on the thread pool being pre-created, and specifically include:
When the quantity for the timed task for needing to execute is multiple, based on multiple threads in the thread pool to multiple institutes Timed task is stated to be executed parallel.
Above-mentioned apparatus, it is preferred that further include:
Monitoring unit is monitored for the implementation procedure to the timed task, and monitored results are fed back to maintenance Personnel.
Above-mentioned apparatus, it is preferred that further include:
Persistence processing unit, for carrying out persistence processing to the timed task, so that in the timed task When interruption, the timed task can be re-executed from the persistence information point of persistence processing gained.
As it can be seen from the above scheme the present invention provides the method and device that a kind of timing executes task, the method includes Obtain preset heartbeat control frequency and preset task execution condition;Wherein, the task execution condition packet Include the timing information executed needed for timed task;Based on scheduled reference instant, timing is carried out using heartbeat control frequency, Obtain clocking information;According to the clocking information and the timing information, whether judgement currently needs to start to execute the timing Task;If so, starting to execute the timed task.It can be seen that the invention discloses a kind of timings based on heartbeat control The implementation of execution task, using application scheme, can by by heartbeat control set of frequency be higher precision grade (such as Ms ranks), so that accordingly control is in higher precision grade (such as ms ranks) by the execution precision of timed task, to apply The present invention program can effectively promote the execution accuracy of timed task.
Description of the drawings
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below There is attached drawing needed in technology description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this The embodiment of invention for those of ordinary skill in the art without creative efforts, can also basis The attached drawing of offer obtains other attached drawings.
Fig. 1-Fig. 5 is the flow diagram for the method that timing provided in an embodiment of the present invention executes task;
Fig. 6-Fig. 8 is the structural schematic diagram for the device that timing provided in an embodiment of the present invention executes task.
Specific implementation mode
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete Site preparation describes, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.It is based on Embodiment in the present invention, it is obtained by those of ordinary skill in the art without making creative efforts every other Embodiment shall fall within the protection scope of the present invention.
The present invention provides the method and devices that a kind of timing executes task, appoint at least solving timing in the prior art The not high enough problem of the execution accuracy of business, to promote the execution accuracy of timed task.Multiple embodiments will be passed through below The method and device that task is executed to the timing of the present invention is described in detail.
With reference to figure 1, Fig. 1 is the method flow diagram that a kind of timing that one embodiment of the present of invention provides executes task, this In embodiment, as shown in Figure 1, the method that the timing executes task includes the following steps:
Step 101 obtains preset heartbeat control frequency and preset task execution condition;Wherein, institute It includes the timing information executed needed for timed task to state task execution condition.
To solve the problems, such as that timed task execution precision of the existing technology is not high enough, the present invention provides one kind to be based on The timing of heartbeat control executes the scheme of task.
In consideration of it, when realizing the execution of timed task, preset heartbeat control frequency need to be obtained first.The heartbeat Controlling frequency supports the frequency of s (second) precision grade and higher precision rank such as ms (millisecond) grade to set, can in practical application Heartbeat is carried out according to the available accuracy demand of its pending task control frequency by related personnel such as technical staff or user etc. Setting.
Simultaneously because the execution of timed task needs, using corresponding conditions as triggering foundation, to also need to obtain timing to appoint The task execution condition of business, the task execution condition of timed task, which generally comprises the related timing executed needed for timed task, to be believed Breath, the timing information can specifically include but are not limited to time started, end time, repeat number and repeat Time interval etc..
Step 102 is based on scheduled reference instant, carries out timing using heartbeat control frequency, obtains clocking information.
The reference instant can equally be preset by technical staff or user according to its actual demand, specifically, than Such as, only (certain timed task such as need to be executed in certain day 6:00 AM for the timed task that certain time point single executes for one Deng), then can by the zero of the same day when (time can read from the time module of time server or system) on the basis of the moment, open Begin to carry out timing using heartbeat control frequency, subsequently when timing duration reaches 6 hours, then can perform single timing and appoint Business.
It for another example, then can be with last timed task for one needs to recycle and executes multiple timed task Finish time on the basis of the moment, start with heartbeat control frequency be when the execution of previous timed task carries out timing, Such as, it is assumed that it was just recycled at interval of 10 minutes and executes a timed task, then it specifically can be in the end of upper primary timed task Moment, 10 minutes when starting with heartbeat control frequency meter, subsequently when timing duration reaches 10 minutes, can start into The task execution process of this timed task of row.
Here, it should be noted that timing is carried out based on heartbeat control frequency in the present invention, essentially refers to be based on the heart It jumps control frequency to be counted, and according to the accumulated number of counting, knows its corresponding duration, for example, it is assumed that in advance The heartbeat set controls frequency as 1000Hz, then when being counted based on heartbeat control frequency, when the accumulated number of counting Reach 6*105When, corresponding timing duration reaches 10 minutes.In practical application, can be used numerical value be incremented by or numerical value increase and decrease Mode carries out timing using set heartbeat control frequency, for example, for 10 minutes timing durations, can be used count value from 0 is incremented to 6*105Mode carry out the timing of the duration, can also use from 6*1050 mode is decremented to complete the duration Timing, the present invention is not construed as limiting its timing mode.
Step 103, according to the clocking information and the timing information, it is described fixed to judge currently whether need to start to execute When task.
As it was noted above, the timing information can include but is not limited to time started, end time, repeat time The relevant information for the task execution condition as timed task such as number, the time interval repeated, in consideration of it, utilizing On the basis of the heartbeat control frequency carries out timing, it can be based on the clocking information and the timing information, to judge to work as It is preceding whether to need to start to execute the timed task.
Specifically, such as, it is assumed that the time interval that multiple timing task need to be repeated, and executed every time be 10 minutes, Then after upper primary timed task executes end and carries out timing based on finish time, when based on set heartbeat control frequency 1000Hz is from 0 incremental count to 6*105(or from 6*105When counting down to 0), correspondingly indicate that timing duration has reached 10 points Clock needs to start to execute to work as previous timed task to have reached the Starting Executing Time for working as previous timed task;Otherwise, If count value is not up to 6*105(or not being decremented to 0) then indicates the Starting Executing Time for also not up to working as previous timed task, from And it needs to continue to count.
Step 104, if so, starting to execute the timed task.
If according to the clocking information and the timing information, judge that currently needing to start to execute the timing appoints Business, for example judge that current time has reached the Starting Executing Time etc. of timed task, then this step starts to execute the timing Task, to realize the timed task implementation procedure controlled based on heartbeat.
As it can be seen from the above scheme the method that timing provided in this embodiment executes task, including obtain the preset heart Jump control frequency and preset task execution condition;Wherein, the task execution condition includes executing timed task institute The timing information needed;Based on scheduled reference instant, timing is carried out using heartbeat control frequency, obtains clocking information;Root According to the clocking information and the timing information, whether judgement currently needs to start to execute the timed task;If so, starting Execute the timed task.It can be seen that the invention discloses the realization sides that a kind of timing based on heartbeat control executes task Case can be higher precision grade (such as ms ranks) by the way that heartbeat is controlled set of frequency, to incite somebody to action using application scheme Accordingly control can have in higher precision grade (such as ms ranks) to apply the present invention program the execution precision of timed task Effect promotes the execution accuracy of timed task.
In the next embodiment of the present invention, continues to provide and obtain preset task execution in the step 101 A kind of possible realization method of condition, with reference to Fig. 2 shows timing execute the method flow diagram of task, in the present embodiment, institute It states and obtains preset task execution condition in step 101, can be realized by processing procedure below:
The task execution condition for the regular expression form that step 1011, acquisition are generated in advance based on Target Setting Mode Or the task execution condition of XML (Extensible Markup Language, extensible markup language) linguistic form.
In the prior art, the sentence of the task execution condition of timed task is arranged, only supports regular expression form, That is, the prior art is only capable of generating the task execution condition of timed task in the form of regular expression, and canonical table Versatility up to formula is relatively low, cross-platform can not use.
To solve this problem, the present invention is on the basis of can support regular expression, it is also proposed that use XML language shape Formula carries out the generation of task execution condition sentence, when the present invention program is embodied, can be parsed by developing in advance The correlative code of the task execution condition of XML language form, to realize the task execution condition sentence progress to XML language form Parsing, is realized with this on the basis of can support regular expression, additionally it is possible to XML language is supported, to timed task Task execution condition when being configured, the form of regular expression or XML language can be used and held to generate required task Row condition.
Compared to regular expression, the versatility of XML language is preferable, cross-platform can use, to which the present embodiment passes through It supports the task execution condition sentence based on XML language form, improves the versatility of system, cross-platform can use.
In another next embodiment of the present invention, continue to illustrate the Setting pattern of timed task.
In the prior art, when the conditional statement to task execution condition is configured, the Setting pattern of conditional statement compared with It is single, underaction is set.To solve the problems, such as this, in the present embodiment, three kinds be configured to task execution condition are provided Setting pattern:First Setting pattern, the second Setting pattern, third Setting pattern enable to support more flexible condition Sentence is arranged.
Wherein, first Setting pattern is used to indicate executes multiple timing at predetermined intervals in the scheduled time Task;Timing parameters defined in the pattern include time started (start-time), end time (end-time), repeat to hold Places number (repeat-count) and the time interval (repeat-interval) repeated.
For example, it is assumed that the execution of timed task need to be from 10:00 starts, and 18:00 terminates, wherein repeats 5 timings and appoints Business, every minor tick 10 minutes, the then task execution condition that can generate the timed task based on first Setting pattern.
Specifically, the task execution condition sentence of regular expression form generated based on first Setting pattern is:
mode1:H/10:00 H/18:00 5M/10;
The task execution condition sentence of XML form generated based on first Setting pattern is:
<mode1>
<condition>H/10:00 H/18:00 5M/10</condition>
</mode1>。
Second Setting pattern is used to indicate each time point in multiple predetermined point of time within a predetermined period of time Execute multiple timing task;Timing parameters defined in the Setting pattern include:The execution period (dual-time, support year, The moon, day, hour, minute), predetermined point of time (do-time, i.e., scheduled one or more particular point in time), repeat time Number (repeat-count) and the time interval (repeat-interval) repeated.
For example, it is assumed that timed task need to execute in one day, and specifically in 8 points, 12 points, 20 points of execution tasks, and every A time point (8 points, 12 points, 20 points) repeats 5 times, and every minor tick 10 minutes can then be based on the second Setting pattern next life At the task execution condition of the timed task.
Specifically, the task execution condition sentence of regular expression form generated based on second Setting pattern is:
mode2:D/1 H/8,12,20 5 M/5;
The task execution condition sentence of XML form generated based on second Setting pattern is:
<mode2>
<condition>D/1 H/8,12,20 5 M/5</condition>
</mode2>
The third Setting pattern is used to indicate the schedule based on calendar and executes timed task;The pattern corresponds to definition There is the parameter of 7 dimensions:Second, minute, hour, which day in one month, month, which day in one week, the time.
For example, it is assumed that timed task need to be on every Mondays, and Tuesday, Wednesday, the evening 20 of Saturday:00 to 23:00 executes, and every Half an hour executes primary, the then task execution condition that can generate the timed task based on the third Setting pattern.
Specifically, the task execution condition sentence of regular expression form generated based on the third Setting pattern is:
mode3:0 0/30 20-23*MON-WED,SAT*;
The task execution condition sentence of XML form generated based on the third Setting pattern is:
<mode3>
<condition>0 0/30 20-23*MON-WED,SAT*</condition>
</mode3>
It, can after the task execution condition for generating regular expression form or XML language form based on corresponding Setting pattern The task execution condition sentence of the regular expression form of generation or XML language form is preserved in systems for spare.
The present embodiment by providing three of the above Setting pattern, overcome the Setting pattern of conditional statement in the prior art compared with The problem of being single, underaction be set, so as to support more flexible conditional statement setting.
In the next further embodiment of the present invention, a kind of possible realization method of the step 104 is provided, is joined It examines the method flow diagram that timing shown in Fig. 3 executes task, in the present embodiment, starts to execute the timing in the step 104 When task, specifically the execution to timed task can be realized by processing procedure below:
Step 1041 executes the timed task based on the thread pool being pre-created.
In this implementation, thread pool by being pre-created is proposed to execute the implementation of timed task, it specifically, can be pre- First create a thread pool for including multiple threads, for example establishment one includes the thread pool etc. of 10 threads, on this basis, when up to When to task execution time, the task can be executed based on the idle thread in the thread pool.
When it is multiple that a certain moment, which needs the quantity of the timed task executed, that is, there are multiple timed tasks while reaching and appoint When business executes the time, each task can be performed in parallel based on multiple idle threads in thread pool, wherein per thread exists Synchronization is only capable of executing a task.If the task quantity for reaching the execution time is more, the thread that leaves unused in thread pool is had exceeded Quantity, then the corresponding task beyond idle number of threads, can be waited for, until some task execution complete from And after so that its corresponding thread is idle, the thread that this could be utilized idle executes being waited for for the task.
As an example it is assumed that including 10 threads altogether in thread pool, then can at most be executed parallel by being based on the thread pool by 10 Task, and for the task beyond the quantity, then it needs to be waited for, until occurring the thread that leaves unused again, can continue Thread is left unused using this to execute being waited for for task.
The present embodiment is when being timed the execution of task based on thread pool, when having multiple timed tasks while reaching task When executing the time, it can be performed in parallel each task based on multiple idle threads in thread pool, adopted compared with the prior art The scheme of each task is executed in serial fashion, and the present embodiment can effectively promote the execution efficiency of timed task.
In the next another embodiment of the present invention, the timing with reference to shown in figure 4 executes the method flow diagram of task, this In embodiment, the method can also include the following steps:
Step 105 is monitored the implementation procedure of the timed task, and monitored results is fed back to maintenance personnel.
The present embodiment when the implementation procedure to the timed task is monitored, specifically can statistics task execute starting The information such as time, end time, time-consuming, the information such as resource consumptions quantity such as CPU/ memories that statistics task executes, statistics task Whether the task that the information such as the idle condition of the thread pool of execution and statistics task execute the information such as interrupts.
It on this basis, can be by the initial time of the task execution of statistics, end time, time-consuming, the resources such as CPU/ memories Quantity consumed, the idle condition of thread pool, whether task the information preservations such as interrupts in the database, and passes through mail, short message etc. Form notifies maintenance personnel, understands task execution situation at any time to maintain easily personnel.
The present embodiment is monitored by the implementation procedure to timed task, and monitored results are fed back to maintenance personnel, Personnel can be maintained easily and understand task execution process at any time, to maintainable well.
In the next another embodiment of the present invention, the timing with reference to shown in figure 5 executes the method flow diagram of task, this In embodiment, the method can also include the following steps:
Step 106 carries out persistence processing to the timed task, so that when the timed task interrupts, it can The timed task is re-executed from the persistence information point of persistence processing gained.
Specifically, task execution progress information is also controlled frequency by the present embodiment while task execution according to heartbeat Persistence is carried out, and corresponding document is written into the persistence information point of persistence processing gained, ordinary file, database is such as written And XML file is medium, subsequently, if task execution is interrupted, can restart system, and after system reboot, reads common text Persistence information point in part, database and XML file, and by the timed task of the interruption from the persistence information point of reading It re-executes.
The present embodiment can be handled by carrying out persistence processing to timed task after may make tasks interrupt from persistence The persistence information point of gained re-executes, to improve the reliability of task execution.
In the next another embodiment of the present invention, a kind of device of timing execution task is provided, with reference to shown in figure 6 Timing executes the structural schematic diagram of the device of task, which includes:
Acquiring unit 100, for obtaining preset heartbeat control frequency and preset task execution condition; Wherein, the task execution condition includes the timing information executed needed for timed task;
Timing unit 200 carries out timing using heartbeat control frequency, obtains for being based on scheduled reference instant Clocking information;
Judging unit 300, for according to the clocking information and the timing information, whether judgement currently to need to start to hold The row timed task;
Task executing units 400, for when the determination result is yes, starting to execute the timed task.
In an embodiment of the embodiment of the present invention, the acquiring unit 100 obtains preset task execution item Part specifically includes:Obtain the task execution condition or XML of the regular expression form being generated in advance based on Target Setting Mode The task execution condition of linguistic form.
In an embodiment of the embodiment of the present invention, when the acquiring unit 100 obtains the task execution condition, institute Based on the Target Setting Mode be the first Setting pattern, the second Setting pattern and third Setting pattern in corresponding modes; Wherein:
First Setting pattern is used to indicate executes multiple timing task at predetermined intervals in the scheduled time; The corresponding timing parameters of first Setting pattern include:Time started, end time repeat number and repeat Time interval;
Second Setting pattern is used to indicate each time point in multiple predetermined point of time within a predetermined period of time Execute multiple timing task;The corresponding timing parameters of second Setting pattern include:Execute period, predetermined point of time, again The time interval for executing number again and repeating;
The third Setting pattern is used to indicate the schedule based on calendar and executes timed task;Mould is arranged in the third The corresponding timing parameters of formula include:Second, minute, hour, which day in one month, month, which day in one week, the time.
In an embodiment of the embodiment of the present invention, the timing unit 200 is specifically used for:
When executing multiple timing task, the moment on the basis of the finish time of last timed task starts with institute It is the execution progress timing when previous timed task to state heartbeat control frequency, obtains clocking information;
Correspondingly, the judging unit 300, is specifically used for:
Between judging whether timing duration that the clocking information includes reaches the time included in the timing information Every if reaching, triggering the task executing units and start to execute the timed task.
In an embodiment of the embodiment of the present invention, the task executing units 400 are specifically used for:Based on advance wound The thread pool built executes the timed task;
Wherein, the task executing units 400 execute the timed task based on the thread pool being pre-created, specific to wrap It includes:When the quantity for the timed task for needing to execute is multiple, based on multiple threads in the thread pool to multiple described fixed When task executed parallel.
In an embodiment of the embodiment of the present invention, with reference to figure 7, described device can also include:Monitoring unit 500, It is monitored for the implementation procedure to the timed task, and monitored results is fed back into maintenance personnel.
In an embodiment of the embodiment of the present invention, with reference to figure 8, described device can also include:Persistence processing is single Member 600, can be from lasting so that when the timed task interrupts for carrying out persistence processing to the timed task The persistence information point for changing processing gained re-executes the timed task.
For timing disclosed by the embodiments of the present invention executes the device of task, since itself and the above various embodiments disclose Timing execute task method it is corresponding, so description it is fairly simple, related similarity refers to the above various embodiments Middle timing executes the explanation of the method part of task, and and will not be described here in detail.
In conclusion compared with the prior art, timing provided by the invention executes the method and device of task with following Advantage:
1) timing execution task is realized based on heartbeat control, the task execution of ms precision grades, task can be supported to hold Capable accuracy is higher;
2) for the setting of timed task conditional statement, on the basis of supporting regular expression, additionally it is possible to support XML languages The conditional statement of speech form improves the versatility of system, cross-platform can use;
3) a variety of Setting patterns for providing task execution condition, overcome the Setting pattern of conditional statement in the prior art It is more single, the problem of underaction is set, so as to support more flexible conditional statement setting;
4) multiple timed tasks are executed based on thread pool parallel, can effectively promotes the execution efficiency of timed task;
5) it is monitored by the implementation procedure to timed task, and monitored results is fed back into maintenance personnel, can facilitated Maintenance personnel understands task execution process at any time, to maintainable well.
It should be noted that each embodiment in this specification is described in a progressive manner, each embodiment weight Point explanation is all difference from other examples, and the same or similar parts between the embodiments can be referred to each other.
For convenience of description, it describes to be divided into various modules when system above or device with function or unit describes respectively. Certainly, the function of each unit is realized can in the same or multiple software and or hardware when implementing the application.
As seen through the above description of the embodiments, those skilled in the art can be understood that the application can It is realized by the mode of software plus required general hardware platform.Based on this understanding, the technical solution essence of the application On in other words the part that contributes to existing technology can be expressed in the form of software products, the computer software product It can be stored in a storage medium, such as ROM/RAM, magnetic disc, CD, including some instructions are used so that a computer equipment (can be personal computer, server either network equipment etc.) executes the certain of each embodiment of the application or embodiment Method described in part.
Finally, it is to be noted that, herein, such as first, second, third and fourth or the like relational terms It is only used to distinguish one entity or operation from another entity or operation, without necessarily requiring or implying these There are any actual relationship or orders between entity or operation.Moreover, the terms "include", "comprise" or its is any Other variants are intended to non-exclusive inclusion, so that including the process, method, article or equipment of a series of elements Include not only those elements, but also include other elements that are not explicitly listed, or further includes for this process, side Method, article or the intrinsic element of equipment.In the absence of more restrictions, limited by sentence "including a ..." Element, it is not excluded that there is also other identical elements in the process, method, article or apparatus that includes the element.
The above is only a preferred embodiment of the present invention, it is noted that for the ordinary skill people of the art For member, various improvements and modifications may be made without departing from the principle of the present invention, these improvements and modifications are also answered It is considered as protection scope of the present invention.

Claims (14)

1. a kind of method that timing executes task, which is characterized in that including:
Obtain preset heartbeat control frequency and preset task execution condition;Wherein, the task execution item Part includes the timing information executed needed for timed task;
Based on scheduled reference instant, timing is carried out using heartbeat control frequency, obtains clocking information;
According to the clocking information and the timing information, whether judgement currently needs to start to execute the timed task;
If so, starting to execute the timed task.
2. according to the method described in claim 1, it is characterized in that, described obtain preset task execution condition, including:
Obtain the task execution condition or extensible markup of the regular expression form being generated in advance based on Target Setting Mode The task execution condition of Language XML linguistic form.
3. according to the method described in claim 2, it is characterized in that, the Target Setting Mode is the first Setting pattern, second Corresponding modes in Setting pattern and third Setting pattern;Wherein:
First Setting pattern is used to indicate executes multiple timing task at predetermined intervals in the scheduled time;It is described The corresponding timing parameters of first Setting pattern include:Time started, end time, the time for repeating number and repeating Interval;
Second Setting pattern is used to indicate the execution of each time point in multiple predetermined point of time within a predetermined period of time Multiple timing task;The corresponding timing parameters of second Setting pattern include:It executes period, predetermined point of time, repeat to hold Places number and the time interval repeated;
The third Setting pattern is used to indicate the schedule based on calendar and executes timed task;The third Setting pattern pair The timing parameters answered include:Second, minute, hour, which day in one month, month, which day in one week, the time.
4. according to the method described in claim 3, it is characterized in that, it is described be based on scheduled reference instant, utilize the heartbeat It controls frequency and carries out timing, including:
When executing multiple timing task, the moment on the basis of the finish time of last timed task starts with the heart It is the execution progress timing when previous timed task to jump control frequency, obtains clocking information;
Correspondingly, described according to the clocking information and the timing information, whether judgement currently needs to start described in execution Timed task, including:
Judge whether the timing duration that the clocking information includes reaches time interval included in the timing information, if Reach, then triggers the step of starting to execute the timed task.
5. according to claim 1-4 any one of them methods, which is characterized in that the execution timed task, including:
The timed task is executed based on the thread pool being pre-created;
Wherein, described that the timed task is executed based on the thread pool being pre-created, including:
When the quantity for the timed task for needing to execute is multiple, based on multiple threads in the thread pool to multiple described fixed When task executed parallel.
6. according to claim 1-4 any one of them methods, which is characterized in that the method further includes:
The implementation procedure of the timed task is monitored, and monitored results are fed back into maintenance personnel.
7. according to claim 1-4 any one of them methods, which is characterized in that the method further includes:
Carrying out persistence processing to the timed task can be handled so that when the timed task interrupts from persistence The persistence information point of gained re-executes the timed task.
8. a kind of timing executes the device of task, which is characterized in that including:
Acquiring unit, for obtaining preset heartbeat control frequency and preset task execution condition;Wherein, institute It includes the timing information executed needed for timed task to state task execution condition;
Timing unit carries out timing using heartbeat control frequency, obtains timing letter for being based on scheduled reference instant Breath;
Judging unit, for according to the clocking information and the timing information, whether judgement currently to need to start described in execution Timed task;
Task executing units, for when the determination result is yes, starting to execute the timed task.
9. device according to claim 8, which is characterized in that the acquiring unit obtains preset task execution Condition specifically includes:
Obtain the task execution condition or XML language form of the regular expression form being generated in advance based on Target Setting Mode Task execution condition.
10. device according to claim 9, which is characterized in that the acquiring unit is obtaining the task execution condition When the Target Setting Mode that is based on be respective mode in the first Setting pattern, the second Setting pattern and third Setting pattern Formula;Wherein:
First Setting pattern is used to indicate executes multiple timing task at predetermined intervals in the scheduled time;It is described The corresponding timing parameters of first Setting pattern include:Time started, end time, the time for repeating number and repeating Interval;
Second Setting pattern is used to indicate the execution of each time point in multiple predetermined point of time within a predetermined period of time Multiple timing task;The corresponding timing parameters of second Setting pattern include:It executes period, predetermined point of time, repeat to hold Places number and the time interval repeated;
The third Setting pattern is used to indicate the schedule based on calendar and executes timed task;The third Setting pattern pair The timing parameters answered include:Second, minute, hour, which day in one month, month, which day in one week, the time.
11. device according to claim 10, which is characterized in that the timing unit is specifically used for:
When executing multiple timing task, the moment on the basis of the finish time of last timed task starts with the heart It is the execution progress timing when previous timed task to jump control frequency, obtains clocking information;
Correspondingly, the judging unit, is specifically used for:
Judge whether the timing duration that the clocking information includes reaches time interval included in the timing information, if Reach, then triggers the task executing units and start to execute the timed task.
12. according to claim 8-11 any one of them devices, which is characterized in that the task executing units are specifically used for: The timed task is executed based on the thread pool being pre-created;
The task executing units execute the timed task based on the thread pool being pre-created, and specifically include:
When the quantity for the timed task for needing to execute is multiple, based on multiple threads in the thread pool to multiple described fixed When task executed parallel.
13. according to claim 8-11 any one of them devices, which is characterized in that described device further includes:
Monitoring unit is monitored for the implementation procedure to the timed task, and monitored results is fed back to maintenance personnel.
14. according to claim 8-11 any one of them devices, which is characterized in that described device further includes:
Persistence processing unit, for carrying out persistence processing to the timed task, so that being interrupted in the timed task When, the timed task can be re-executed from the persistence information point of persistence processing gained.
CN201810076694.5A 2018-01-26 2018-01-26 A kind of timing executes the method and device of task Pending CN108279971A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810076694.5A CN108279971A (en) 2018-01-26 2018-01-26 A kind of timing executes the method and device of task

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810076694.5A CN108279971A (en) 2018-01-26 2018-01-26 A kind of timing executes the method and device of task

Publications (1)

Publication Number Publication Date
CN108279971A true CN108279971A (en) 2018-07-13

Family

ID=62805378

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810076694.5A Pending CN108279971A (en) 2018-01-26 2018-01-26 A kind of timing executes the method and device of task

Country Status (1)

Country Link
CN (1) CN108279971A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109189564A (en) * 2018-08-01 2019-01-11 北京奇虎科技有限公司 A kind of task processing method and device
CN109240994A (en) * 2018-08-01 2019-01-18 北京奇虎科技有限公司 A kind of document handling method and device
CN110990144A (en) * 2019-12-17 2020-04-10 深圳市晨北科技有限公司 Task determination method and related equipment

Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1965294A (en) * 2004-06-11 2007-05-16 佳能株式会社 Service providing apparatus, service providing method, and control program
CN101296289A (en) * 2007-04-27 2008-10-29 株式会社理光 Image forming device, information processing method, and information processing program
CN101320337A (en) * 2008-07-16 2008-12-10 北京中星微电子有限公司 Timer and its implementing method
CN101561755A (en) * 2008-04-18 2009-10-21 北京闻言科技有限公司 Method for flexibly scheduling time of timer
CN101901164A (en) * 2009-05-27 2010-12-01 北京金山软件有限公司 Time plan scheduler module and method
CN102521388A (en) * 2011-12-23 2012-06-27 国网电力科学研究院 Low-coupling high-availability device for electric power information retrieval
CN102566992A (en) * 2010-12-17 2012-07-11 卓望数码技术(深圳)有限公司 Dependency injection method and dependency injection device based on system running
CN103023716A (en) * 2012-11-26 2013-04-03 中怡(苏州)科技有限公司 System and method for monitoring network quality with zero traffic consumption
CN103067597A (en) * 2013-01-05 2013-04-24 广东欧珀移动通信有限公司 Mobile terminal startup task execution method
CN103595559A (en) * 2013-11-05 2014-02-19 深圳市远行科技有限公司 System and method for transmitting big data and service system thereof
CN103746990A (en) * 2013-12-31 2014-04-23 梵飞(厦门)文化传播有限公司 Data interaction system and data interaction method for browser and client in mobile terminal
CN105338086A (en) * 2015-11-04 2016-02-17 浪潮软件股份有限公司 Distributed message forwarding method
CN106535309A (en) * 2016-10-28 2017-03-22 珠海市魅族科技有限公司 Method and device for keeping network connection

Patent Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1965294A (en) * 2004-06-11 2007-05-16 佳能株式会社 Service providing apparatus, service providing method, and control program
CN101296289A (en) * 2007-04-27 2008-10-29 株式会社理光 Image forming device, information processing method, and information processing program
CN101561755A (en) * 2008-04-18 2009-10-21 北京闻言科技有限公司 Method for flexibly scheduling time of timer
CN101320337A (en) * 2008-07-16 2008-12-10 北京中星微电子有限公司 Timer and its implementing method
CN101901164A (en) * 2009-05-27 2010-12-01 北京金山软件有限公司 Time plan scheduler module and method
CN102566992A (en) * 2010-12-17 2012-07-11 卓望数码技术(深圳)有限公司 Dependency injection method and dependency injection device based on system running
CN102521388A (en) * 2011-12-23 2012-06-27 国网电力科学研究院 Low-coupling high-availability device for electric power information retrieval
CN103023716A (en) * 2012-11-26 2013-04-03 中怡(苏州)科技有限公司 System and method for monitoring network quality with zero traffic consumption
CN103067597A (en) * 2013-01-05 2013-04-24 广东欧珀移动通信有限公司 Mobile terminal startup task execution method
CN103595559A (en) * 2013-11-05 2014-02-19 深圳市远行科技有限公司 System and method for transmitting big data and service system thereof
CN103746990A (en) * 2013-12-31 2014-04-23 梵飞(厦门)文化传播有限公司 Data interaction system and data interaction method for browser and client in mobile terminal
CN105338086A (en) * 2015-11-04 2016-02-17 浪潮软件股份有限公司 Distributed message forwarding method
CN106535309A (en) * 2016-10-28 2017-03-22 珠海市魅族科技有限公司 Method and device for keeping network connection

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
严隽薇、严隽永: "《计算机实时控制软件设计导论》", 28 February 1990 *
及德增: "《程控交换技术与应用》", 31 March 2008 *
闫晓东,王志娟,韩丽: "《多语言网络资源搜索新技术》", 31 December 2009 *
陈燕,李桃迎: "《信息系统集成技术与方法教程》", 31 October 2015 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109189564A (en) * 2018-08-01 2019-01-11 北京奇虎科技有限公司 A kind of task processing method and device
CN109240994A (en) * 2018-08-01 2019-01-18 北京奇虎科技有限公司 A kind of document handling method and device
CN110990144A (en) * 2019-12-17 2020-04-10 深圳市晨北科技有限公司 Task determination method and related equipment

Similar Documents

Publication Publication Date Title
CN108279971A (en) A kind of timing executes the method and device of task
US10062043B2 (en) System and method for dynamically coordinating tasks, schedule planning, and workload management
JP4977729B2 (en) Job schedule change support system, method and program
Izosimov et al. Scheduling of fault-tolerant embedded systems with soft and hard timing constraints
WO2008000588A3 (en) Managing flexible events within an electronic calendar
US11705754B2 (en) Method and devices for optimizing backup power control using machine learning
US20020172097A1 (en) Methods and apparatus for low power delay control
CN102736512A (en) Electronic device and system time setting method thereof
CN108958915A (en) Timed task executes method and device
CN111522719A (en) Method and device for monitoring big data task state
Sprecher Network decomposition techniques for resource-constrained project scheduling
WO2015188016A2 (en) Energy-efficient real-time task scheduler
Abdeddaïm et al. Real-time scheduling of energy harvesting embedded systems with timed automata
CN107797856B (en) Scheduled task management and control method and device based on windows service and storage medium
CN109697218A (en) The more write methods of efficient isomeric data and system based on configuration strategy
CN103383546B (en) Multi-period timed power on/off method and device
Smith et al. An effective algorithm for project scheduling with arbitrary temporal constraints
Kostreva et al. Using a circadian rhythms model to evaluate shift schedules
JP2008217628A (en) Cpu power saving system and power saving method
CN110851256A (en) Data calculation scheduling method based on electric power big data
TW200532405A (en) Timer system and method capable of dynamically compensating for the imprecision of a timer
CN113406992A (en) System clock control method, processing device and readable storage medium
Karimi et al. CARTOS: A Charging-Aware Real-Time Operating System for Intermittent Batteryless Devices
CN111552545A (en) Task execution processing method and device, electronic equipment and storage medium
JP2003270371A (en) Clock device in computer system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20180713

RJ01 Rejection of invention patent application after publication