CN110471752A - Task executing method, device, electronic equipment and computer readable storage medium - Google Patents

Task executing method, device, electronic equipment and computer readable storage medium Download PDF

Info

Publication number
CN110471752A
CN110471752A CN201910726146.7A CN201910726146A CN110471752A CN 110471752 A CN110471752 A CN 110471752A CN 201910726146 A CN201910726146 A CN 201910726146A CN 110471752 A CN110471752 A CN 110471752A
Authority
CN
China
Prior art keywords
task
classification
time
force
duration
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
CN201910726146.7A
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.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network Co 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 Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN201910726146.7A priority Critical patent/CN110471752A/en
Publication of CN110471752A publication Critical patent/CN110471752A/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

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

Embodiment of the present disclosure provides a kind of task executing method, task execution device, electronic equipment and computer readable storage medium, is related to field of computer technology.The task executing method includes: to be classified according to the duration that comes into force of task to task;In each category, task is ranked up according to the creation time of task;Task is executed according to the task ranking result in each classification.As it can be seen that implementing the embodiment of the present disclosure is able to ascend task execution efficiency, improve the usage experience of user.

Description

Task executing method, device, electronic equipment and computer readable storage medium
Technical field
Embodiment of the present disclosure is related to field of computer technology, more specifically, embodiment of the present disclosure is related to task Execution method, task execution device, electronic equipment and computer readable storage medium.
Background technique
Under normal conditions, terminal can be according to timed task set by user or the timed task of application triggers to user Prompting message is carried out, for example, sending short message to user equipment according to sending short messages at definite time task timing.
Specifically, terminal can establish multiple timed tasks, and carry out continuous poll to multiple timed tasks;Wherein, no The same timed task usually corresponding entry-into-force time is also different.If the entry-into-force time of being polled to for task arrived, to corresponding User carry out prompting message;If the entry-into-force time of being polled to for task does not reach, continue poll other tasks until next It detects that its entry-into-force time reaches when secondary poll to the task, and then prompting message is carried out to corresponding user.
When terminal needs a large amount of timed task of poll, it be easy to cause the task entry-into-force time arrived by the above method But the problem of non-poll to task, it is inefficient to will lead to task execution in this way.
It should be noted that information is only used for reinforcing the reason to the background of the disclosure disclosed in above-mentioned background technology part Solution, therefore may include the information not constituted to the prior art known to persons of ordinary skill in the art.
Summary of the invention
It can be seen that the execution of timed task, there are time delays in the related technology, that is, the task entry-into-force time arrived but It is non-poll to the task, causes the task not to be performed in time, in turn result in the inefficient problem of task execution.
Thus, it is also very desirable to which a kind of improved task executing method executes this when reaching the task entry-into-force time in time Business, to promote task execution efficiency, improves the usage experience of user.
In the present context, embodiment of the present disclosure provides task executing method, task execution device, electronic equipment And computer readable storage medium.
According to the first aspect of the embodiments of the present disclosure, a kind of task executing method is disclosed, comprising:
Classified according to the duration that comes into force of task to task;
In each category, task is ranked up according to the creation time of task;
Task is executed according to the task ranking result in each classification.
In one embodiment, aforementioned schemes are based on, are classified according to the duration that comes into force of task to task, comprising:
If task is ranged target category there are task corresponding target category in existing classification;
If target category is not present in existing classification, creates new category and task is ranged into new category.
In one embodiment, aforementioned schemes are based on, task is ranked up according to the creation time of task, comprising:
Task is ranked up according to by the early time sequencing to evening according to the creation time of task.
In one embodiment, aforementioned schemes, the task executing method are based on further include:
Corresponding scanning thread is set for each classification, to scan the task in each classification respectively by scanning thread.
In one embodiment, aforementioned schemes are based on, task, packet are executed according to the task ranking result in each classification It includes:
If the scanning the classification of thread Current Scan of the task does not meet the corresponding duration that comes into force, according to coming into force, duration is determined Waiting time, to execute the task of Current Scan after waiting time;And
Next task is scanned according to the task ranking result of the category.
In one embodiment, aforementioned schemes are based on, duration determines waiting time according to coming into force, comprising:
Calculate Current Scan task creation time with come into force duration and, as task execution time;
The time interval for determining task execution time and current time, as waiting time.
In one embodiment, aforementioned schemes, the task executing method are based on further include:
Determine the corresponding identifier of task in each classification;Wherein, in classification, identifier is according to task ranking result It is incremented by successively by 1.
According to the second aspect of an embodiment of the present disclosure, it discloses a kind of task execution device, including classification of task unit, appoints Business sequencing unit and task executing units, in which:
Classification of task unit, for being classified according to the duration that comes into force of task to task;
Task ranking unit, in each category, being ranked up according to the creation time of task to task;
Task executing units, for executing task according to the task ranking result in each classification.
In one embodiment, aforementioned schemes are based on, classification of task unit carries out task according to the duration that comes into force of task The mode of classification specifically:
If task is ranged target category by classification of task unit there are task corresponding target category in existing classification;
If target category is not present in existing classification, task is simultaneously ranged new class by classification of task unit creation new category Not.
In one embodiment, aforementioned schemes are based on, task ranking unit carries out task according to the creation time of task The mode of sequence specifically:
Task ranking unit is ranked up task according to by the early time sequencing to evening according to the creation time of task.
In one embodiment, aforementioned schemes are based on, which further includes scanning thread setting unit, In:
Thread setting unit is scanned, for corresponding scanning thread to be arranged for each classification, to pass through scanning thread difference Scan the task in each classification.
In one embodiment, aforementioned schemes are based on, task executing units are according to the task ranking result in each classification The mode of execution task specifically:
If the scanning the classification of thread Current Scan of the task does not meet the corresponding duration that comes into force, task executing units are according to life Effect duration determines waiting time, to execute the task of Current Scan after waiting time;And
Task executing units scan next task according to the task ranking result of the category.
In one embodiment, aforementioned schemes are based on, task executing units determine the side of waiting time according to the duration that comes into force Formula specifically:
Task executing units calculate Current Scan task creation time with come into force duration and, when as task execution Between;
Task executing units determine the time interval of task execution time and current time, as waiting time.
In one embodiment, aforementioned schemes are based on, which further includes identifier determination unit, in which:
Identifier determination unit, for determining the corresponding identifier of task in each classification;Wherein, in classification, mark It is incremented by successively by 1 according to task ranking result to know symbol.
According to the third aspect of an embodiment of the present disclosure, a kind of electronic equipment is disclosed, comprising: processor;And memory, It is stored with computer-readable instruction on memory, is realized as disclosed in first aspect when computer-readable instruction is executed by processor Task executing method.
According to a fourth aspect of embodiments of the present disclosure, a kind of computer program medium is disclosed, computer is stored thereon with Readable instruction executes computer according to disclosure first party when computer-readable instruction is executed by the processor of computer Task executing method disclosed in face.
The embodiment of the present disclosure can classify to task by the duration that comes into force of task (e.g., timed task), Ke Yili The task of the identical duration that comes into force is classified as one kind by Xie Wei, also, in each category, can be according to the creation time pair of task Task, which is ranked up, (e.g., to be ranked up by the early sequence to evening according to creation time, or is carried out by evening to early according to creation time Sequence), in turn, the task in each classification can be executed respectively according to ranking results, it can be understood as in each classification Task is performed simultaneously.Compared with the prior art, on the one hand the task can be executed in time when reaching the task entry-into-force time, to be promoted Task execution efficiency improves the usage experience of user;On the other hand the occupancy for computer resource can be reduced, to promote money Source utilization rate.
Other characteristics and advantages of the disclosure will be apparent from by the following detailed description, or partially by the disclosure Practice and acquistion.
It should be understood that the above general description and the following detailed description are merely exemplary, this can not be limited It is open.
Detailed description of the invention
The following detailed description is read with reference to the accompanying drawings, above-mentioned and other mesh of disclosure illustrative embodiments , feature and advantage will become prone to understand.In the accompanying drawings, if showing the disclosure by way of example rather than limitation Dry embodiment, in which:
Shown in fig. 1 is the flow diagram according to the task executing method of one example embodiment of the disclosure;
Fig. 2 shows be being classified to task according to the duration that comes into force of task according to one example embodiment of the disclosure Flow diagram;
Fig. 3 shows executing according to the task ranking result in each classification according to one example embodiment of the disclosure The logic of task realizes schematic diagram;
Fig. 4 shows the structural block diagram of the task execution device according to one example embodiment of the disclosure;
Fig. 5 shows the structural block diagram of the task execution device according to another optional example embodiment of the disclosure.
In the accompanying drawings, identical or corresponding label indicates identical or corresponding part.
Specific embodiment
The principle and spirit of the disclosure are described below with reference to several illustrative embodiments.It should be appreciated that providing this A little embodiments are used for the purpose of making those skilled in the art can better understand that realizing the disclosure in turn, and be not with any Mode limits the scope of the present disclosure.On the contrary, these embodiments are provided so that this disclosure will be more thorough and complete, and energy It is enough that the scope of the present disclosure is completely communicated to those skilled in the art.
One skilled in the art will appreciate that embodiment of the present disclosure can be implemented as a kind of system, device, equipment, method Or computer program product.Therefore, the present disclosure may be embodied in the following forms, it may be assumed that complete hardware, complete software The form that (including firmware, resident software, microcode etc.) or hardware and software combine.
According to embodiment of the present disclosure, propose a kind of task executing method, task execution device, electronic equipment and Computer readable storage medium.
Any number of elements in attached drawing is used to example rather than limitation and any name are only used for distinguishing, without With any restrictions meaning.
Below with reference to several representative embodiments of the disclosure, the principle and spirit of the disclosure are illustrated in detail.
Summary of the invention
Applicants have discovered that need to complete by multiple or a plurality of types of tasks during service implementation, these Business is usually to be performed in a manner of periodically coming into force, also, the different types of task corresponding entry-into-force time generally also may It is inconsistent.Even the business of same type, the corresponding entry-into-force time may also can be inconsistent, such as belong to coupon type The entry-into-force time of business, a generic task (full 100 subtract 20) in the business is to come into force from after creation 10 days, b generic task (certificate value etc. Volume is exchanged) entry-into-force time be to come into force from after creation 5 days, the entry-into-force time of c generic task (full 500 subtract 199) is from after creation 3 days It comes into force.
Current existing way is typically required the timed task by the starting scanning continuous poll whole of thread, and foundation is worked as Whether preceding task reaches the triggered time to determine whether to execute the task;It is possible to further according to different task type wounds Different task scan threads is built, and needs to carry out the poll repeatedly of global or local, is also resulted in during poll Task is delayed by execution because missing poll opportunity, it is understood that is, it is assumed that when not reaching execution when task a is polled also Between, scanning thread skips task a access next task, and at this moment task a reaches exactly to execute the time again, at this point, task a can only Until next time, poll Shi Caihui is accessed to, if the task amount being polled has 1,000,000, the execution time of task a It will be significantly delayed.
During thinking deeply the problem, the applicant expects to solve the above problems by increasing scanning thread, But increasing scanning thread means to occupy more cpu resources, and (e.g., task amount reaches million grades when task amount is larger More than), still can there are problems that above-mentioned task execution time is delayed by.
In further thinking, the applicant has investigated a kind of task executing method, comprising: according to coming into force for task Duration classifies to task;In each category, task is ranked up according to the creation time of task;According to each classification In task ranking result execute task.It, can be timely when reaching the task entry-into-force time by implementing embodiment of the disclosure The task is executed, to promote task execution efficiency, improves the usage experience of user;And it can reduce for computer resource Occupancy, to promote resource utilization.
After describing the basic principle of the disclosure, lower mask body introduces the various non-limiting embodiment party of the disclosure Formula.
Application scenarios overview
It should be noted that following application scenarios are merely for convenience of understanding the spirit of the disclosure and principle and showing, this Disclosed embodiment is unrestricted in this regard.On the contrary, embodiment of the present disclosure can be applied to it is applicable any Scene.
Embodiment of the disclosure can be applied to the business platform there are timed task, and e.g., electric business platform, operator are flat Platform, game management platform or network content management platform etc..Wherein, electric business platform, which exists, needs to be arranged in the server timing certainly There is the set meal short message for needing timing to different user transmission in dynamic entry-into-force time, operator's platform, game management platform has need It periodically to push the timed task (e.g., the harvest time of planting vegetable in game) in game to user to remind, Web content Manage platform exist need timing pop-up corresponding web page link (e.g., user browse a webpage time be more than preset time it Afterwards, determine user it is interested in the content of the webpage, and then user browsing webpage in pop-up it is relevant to the webpage other The link of webpage), it is seen then that above-mentioned platform is suitable for embodiment of the disclosure.In addition, most of application programs require user The operation that Account Registration is carried out when using for the first time, after a period of time of succeeding in registration, application program would generally be short by sending The mode of letter notifies the registered success of user, and the disclosure can be applied to timing and send to different user for indicating to succeed in registration Short message, that is, classified according to the duration that comes into force of task to task, and in each category, according to the creation time of task Task is ranked up, and then task is executed according to the task ranking result in each classification, it in this way can be when task comes into force Between reach when execute the task in time, to promote task execution efficiency, improve the usage experience of user.
Illustrative methods
Below with reference to above-mentioned application scenarios, described with reference to FIG. 1 to FIG. 3 appointing according to disclosure illustrative embodiments Business execution method.
Referring to Fig. 1, shown in fig. 1 illustrated according to the process of the task executing method of one example embodiment of the disclosure Figure, the task executing method can be realized by server or terminal device.
As shown in Figure 1, including: according to the task executing method of one embodiment of the disclosure
Step S110: classified according to the duration that comes into force of task to task.
Step S120: in each category, task is ranked up according to the creation time of task.
Step S130: task is executed according to the task ranking result in each classification.
These steps are described in detail below.
In step s 110, classified according to the duration that comes into force of task to task.
In an exemplary embodiment of the disclosure, task can be understood as timed task (e.g., a discount coupon life after 10 hours The task of effect), the duration that comes into force of task can be understood as the task can be performed after the duration that comes into force of creation time.It lifts For example, the task that a discount coupon comes into force after 10 hours, the creation time of task is 0 minute and 0 second 0 point of January 1, a length of 10 when coming into force Hour, then, terminal or server can January 1 10 points so that a discount coupon is come into force within 0 second 0 minute.
In an exemplary embodiment of the disclosure, specifically may be used according to the duration that comes into force of task to the mode that task is classified With are as follows: the task that the duration that comes into force belongs to same range is divided into one kind according to duration range is come into force, e.g., by a length of 1 day when coming into force Within be divided into one kind, one kind will be divided between when coming into force a length of 1 day to 3 days, will be a length of between 3 days to 1 month when coming into force Be divided into one kind etc.;Alternatively, the identical task of duration that will come into force is divided into one kind, embodiment of the disclosure is not construed as limiting.
In an exemplary embodiment of the disclosure, optionally, referring to Fig. 2, Fig. 2 shows be according to one example of the disclosure The flow diagram of embodiment classified according to the duration that comes into force of task to task.As shown in Fig. 2, according to the life of task Effect duration classifies to task, comprising:
Step S210: if task is ranged target category there are task corresponding target category in existing classification.
Step S210: it if target category is not present in existing classification, creates new category and task is ranged into new category.
These steps are described in detail below.
In step S210, if task is ranged target class there are task corresponding target category in existing classification Not.
In an exemplary embodiment of the disclosure, one or more classifications are provided in terminal or server, to fixed When task classify, plurality of classes if it exists, there are at least one tasks in any classification.
In an exemplary embodiment of the disclosure, if there are the corresponding target categories of task in existing classification, by task Target class is ranged to be specifically as follows otherwise:
According to the content of task determine task belonging to target category (e.g., the task that a discount coupon comes into force after 10 hours);
Detection, which currently has, whether there is target category in classification, and if it exists, the task is then ranged into target category, if It is not present, thens follow the steps S220.
In step S220, if target category is not present in existing classification, creates new category and range task newly Classification.
In an exemplary embodiment of the disclosure, which can also include:
If there is the classification without task in existing classification, deleting the category and closing the corresponding scanning thread of the category;Or Person
If there is the classification without task in existing classification, terminate the polling operation of the corresponding scanning thread of the category.
As it can be seen that implementing the optional embodiment, the occupancy for computer resource can be reduced, to promote the utilization of resources Rate.
As it can be seen that implement the flow chart that the duration that comes into force shown in Fig. 2 according to task classifies to task, it can be by right Task while poll under different classes of, promote task execution efficiency.
In the step s 120, in each category, task is ranked up according to the creation time of task.
In an exemplary embodiment of the disclosure, task ranking operation is performed simultaneously in of all categories.
In an exemplary embodiment of the disclosure, optionally, task is ranked up according to the creation time of task, is wrapped It includes:
Task is ranked up according to by the early time sequencing to evening according to the creation time of task.
In an exemplary embodiment of the disclosure, optionally, task is ranked up according to the creation time of task, it can also To include: to be ranked up according to by evening to early time sequencing according to the creation time of task to task, embodiment of the disclosure It is not construed as limiting.
As it can be seen that implementing the optional embodiment, it is only necessary to according to the sequence of timed task gradually inquire whether received letter of acceptance Moment, without all timed tasks in the entire classification of poll every time, to promote the polling efficiency and task of task Execution efficiency.
In step s 130, task is executed according to the task ranking result in each classification.
In an exemplary embodiment of the disclosure, optionally, task is executed according to the task ranking result in each classification, Include:
If the scanning the classification of thread Current Scan of the task does not meet the corresponding duration that comes into force, according to coming into force, duration is determined Waiting time, to execute the task of Current Scan after waiting time;And
Next task is scanned according to the task ranking result of the category.
Further, waiting time is determined according to the duration that comes into force, comprising:
Calculate Current Scan task creation time with come into force duration and, as task execution time;
The time interval for determining task execution time and current time, as waiting time.
For example, if a length of 5 minutes when the coming into force of task of scanning thread Current Scan, creation time is January 1 Day 0 point 0 second 0 minute, then, according to calculate creation time and the duration that comes into force and, can determine what the task should be performed Time is 5 minutes and 0 second 0 point of January 1.If current time is 4 minutes and 0 second 0 point of January 1, then, the waiting time can then hold for task The time interval of row time and current time, i.e., 1 minute.
In addition, it should be noted that, in embodiment of the disclosure, scanning thread is to appointing after sorting in each classification Business is scanned, i.e. the task of Current Scan has been the timed task nearest apart from the entry-into-force time, in this way can be to avoid such The timed task of sequence rearward misses the entry-into-force time because not being scanned in not.
As it can be seen that implement the optional embodiment, it can be by a poll it is determined that being immediately performed task still pre- If executing the task after duration, reduce the wrap count for task list, reduce the waste for computer resource, is promoted Task execution efficiency.
As it can be seen that implementing task executing method shown in FIG. 1, this can be executed in time when reaching the task entry-into-force time Business, to promote task execution efficiency, improves the usage experience of user;And occupancy for computer resource can be reduced, with Promote resource utilization.
In an exemplary embodiment of the disclosure, optionally, the task executing method further include:
Corresponding scanning thread is set for each classification, to scan the task in each classification respectively by scanning thread.
In an exemplary embodiment of the disclosure, scanning thread is for being polled the task in classification.
As it can be seen that implement the optional embodiment, it can be by the way that multiple scanning threads be arranged, so that the poll in of all categories It carries out simultaneously, to promote the polling efficiency for task.
In an exemplary embodiment of the disclosure, optionally, the task executing method further include:
Determine the corresponding identifier of task in each classification;Wherein, in each classification, identifier is according to task ranking As a result incremented by successively by 1.
In an exemplary embodiment of the disclosure, identifier is for indicating task the location of in respective classes.This Outside, may exist identical identifier in different classes of, identical identifier is not present in same category.
As it can be seen that implement the optional embodiment, by determining corresponding identifier for task, with it is clear its in task list In position, and then corresponding thread of all categories can be made quickly to navigate to when being scanned and need the task location that scans, Further improve polling efficiency.
Referring to Fig. 3, Fig. 3 shows arranging according to the task in each classification according to one example embodiment of the disclosure The logic that sequence result executes task realizes schematic diagram.As shown in figure 3, executing task according to the task ranking result in each classification Logic realize schematic diagram diagrammatically illustrate A class timed task, B class timed task and C class timed task.A class timing is appointed Business, B class timed task and C class timed task respectively correspond independent scanning thread;Wherein, the corresponding life of A class timed task The effect time is x, that is, task can be executed after x, the B class timed task corresponding entry-into-force time is y, that is, can be executed after y Task, C class timed task corresponding entry-into-force time are z, that is, task can be executed after z, specifically:
A class timed task includes task A1, task A2, task A3, task A4 and task An, wherein n is greater than 4 and n and is Positive integer, if n is greater than 5, then, there are at least one tasks between task A4 and task An;In addition, the identifier of task A1 It is 1, the identifier of task A2 is 2, and the identifier of task A3 is 3, and the identifier of task A4 is 4, and the identifier of task An is n, It is that task allocation identification accords with that terminal device or server, which are according to the creation time of timed task, and identifier is for indicating its wound Build the sequencing of time, e.g., the creation time (e.g., when 1 day 1 January in 2019 1 divide 1 second) of the task A1 that identifier is 1 earlier than The creation time (e.g., 2019 2 months 2 days 2 when 2 divide 2 seconds) for the task A2 that identifier is 2.In addition, the current execution of A generic task Displacement is 1, and terminal or server can be successively polled according to the numerical order that identifier indicates, by the task of current poll Next polling tasks known to task A1 are task A2.
B class timed task includes task B1, task B2, task B3, task B4 and task Bn, wherein n is greater than 4 and n and is Positive integer, if n is greater than 5, then, there are at least one tasks between task B4 and task Bn;In addition, the identifier of task B1 It is 1, the identifier of task B2 is 2, and the identifier of task B3 is 3, and the identifier of task B4 is 4, and the identifier of task Bn is n, It is that task allocation identification accords with that terminal device or server, which are according to the creation time of timed task, and identifier is for indicating its wound The sequencing of time is built, e.g., when creation of the creation time for the task B1 that identifier is 1 earlier than the task B2 that identifier is 2 Between.In addition, the current execution displacement of B generic task is 2, terminal or server can be according to the numerical orders that identifier indicates successively It is polled, the task by current poll is that task B2 knows that next polling tasks are task B3.
C class timed task includes task C1, task C2, task C3, task C4 and task Cn, wherein n is greater than 4 and n and is Positive integer, if n is greater than 5, then, there are at least one tasks between task C4 and task Cn;In addition, the identifier of task C1 It is 1, the identifier of task C2 is 2, and the identifier of task C3 is 3, and the identifier of task C4 is 4, and the identifier of task Cn is n, It is that task allocation identification accords with that terminal device or server, which are according to the creation time of timed task, and identifier is for indicating its wound The sequencing of time is built, e.g., when creation of the creation time for the task C1 that identifier is 1 earlier than the task C2 that identifier is 2 Between.In addition, the current execution displacement of C generic task is 1, terminal or server can be according to the numerical orders that identifier indicates successively It is polled, the task by current poll is that task C4 knows that next polling tasks are task C5.
Wherein, it should be noted that terminal or server can be fixed to A class timed task, B class timed task and C class When task simultaneous wheels ask;It can also be according to preset time interval, to A class timed task, B class timed task and C class timing Task starts poll respectively, e.g., first poll A class timed task, poll B class timed task after preset time, another preset time Poll C class timed task afterwards;Successively A class timed task, B class timed task and C class timed task can also be polled, Such as, poll B class timed task after A class timed task poll is complete, poll C class timed task, this public affairs after B class timed task poll is complete The embodiment opened is not construed as limiting.
For example, if A class timed task, B class timed task and C class timed task are periodically to send short messages to appoint Business, x 1, y 2, z 3, that is, A class timed task is coming into force after 1 hour from creation for task, and B class timed task is to create certainly Coming into force after building up 2 hours for task, C class timed task are coming into force after 3 hours from creation for task.Wherein, A class timing is appointed For business, scanning thread may determine that the triggered time for currently whether reaching task A1, if not up to, it is determined that need to wait for out Duration and execute task A1 when reaching the duration and be immediately performed task A1 if reached, and then scanning thread is moved to Task A2, similarly for B class timed task and C class timed task.Wherein, the triggered time is creation time and the duration that comes into force With.
By taking A class timed task as an example, the waiting time of task, corresponding data structure was as follows:
By taking A class timed task as an example, it is as follows that the execution of Current Scan thread is displaced corresponding data structure:
In conjunction with above-mentioned data structure, in embodiment of the disclosure, terminal device or server can be by after_ The identical task of effective_time is classified as one kind;Wherein, when business root creates certain class business according to the entry-into-force time of business It can specify after_effective_time:x when timed task.In turn, when timed task system receives the timing of such business After task creation request, system can first inquire itself whether created uniquely corresponding according to after_effective_time Business is sorted out, if it is present by business timed task Task { " task_type ";" A ", " create_point ": " current_timestamp ", " after_effective_time ": x } insertion storage system in (storage can be mysql, Other any storage systems such as kv database, embodiment of the disclosure are not construed as limiting;If it does not exist, then creation task is sorted out Current_offset { " A ", 0 } and persistence (that is, the category is stored), and corresponding task is created for the category Thread threadA is scanned, then creates A category task.
Further, task scan thread threadA can sort out according to the task of itself processing, first obtain corresponding Current_offsetA inquires specific business timed task taskA according to offset and task_type.Task scan line Journey threadA gets specific business timed task taskA, according to (the create_point+after_ in taskA Effective_time it) makes comparisons with current time current, if current < (create_point+after_ Effective_time), then threadA waiting time (create_point+after_effective_time- is allowed current);Otherwise taskA is executed, in turn, the offset value in Current_offsetA is added one, so that scanning thread Corresponding next task is scanned, continues to repeat the above process, to realize the poll to task;Wherein, offset value with Identifier is mapping relations, for example, offset value corresponding to the task that identifier is 1 can be 1, or 2,3 Or 4 etc..
As it can be seen that the logic for executing task according to the task ranking result in each classification as shown in connection with fig. 3 realizes signal Figure implements embodiment of the disclosure, can execute in time the task when reaching the task entry-into-force time, to promote task execution effect Rate improves the usage experience of user;And occupancy for computer resource can be reduced, to promote resource utilization.
In addition, although describing each step of method in the disclosure in the accompanying drawings with particular order, this does not really want These steps must be executed in this particular order by asking or implying, or having to carry out step shown in whole could realize Desired result.Additional or alternative, it is convenient to omit multiple steps are merged into a step and executed by certain steps, and/ Or a step is decomposed into execution of multiple steps etc..
Exemplary media
After the method for describing disclosure illustrative embodiments, next, to disclosure illustrative embodiments Medium be illustrated.
In some possible embodiments, various aspects of the disclosure is also implemented as a kind of medium, stores thereon There is program code, when program code is executed by the processor of equipment for realizing above-mentioned " illustrative methods " part of this specification Described according to the step in the task executing method of the various illustrative embodiments of the disclosure.
Specifically, for realizing following steps when the processor of the equipment executes said program code: according to task The duration that comes into force classifies to task;In each category, task is ranked up according to the creation time of task;According to each Task ranking result in classification executes task.
In some embodiments of the disclosure, the processor of the equipment is also used to realize when executing said program code Following steps: if task is ranged target category there are task corresponding target category in existing classification;If existing classification In be not present target category, then create new category and task ranged into new category.
In some embodiments of the disclosure, the processor of the equipment is also used to realize when executing said program code Following steps: task is ranked up according to by the early time sequencing to evening according to the creation time of task.
In some embodiments of the disclosure, the processor of the equipment is also used to realize when executing said program code Following steps: being arranged corresponding scanning thread for each classification, to scan the task in each classification respectively by scanning thread.
In some embodiments of the disclosure, for realizing such as when the processor of the equipment executes said program code Lower step: if the task of the classification of scanning thread Current Scan does not meet the corresponding duration that comes into force, according to coming into force, duration is determined Waiting time, to execute the task of Current Scan after waiting time;And according under the scanning of the task ranking result of the category One task.
In some embodiments of the disclosure, the processor of the equipment is also used to realize when executing said program code Following steps: calculate the creation time of the task of Current Scan and the duration that comes into force and, as task execution time;Determine task The time interval for executing time and current time, as waiting time.
In some embodiments of the disclosure, the processor of the equipment is also used to realize when executing said program code Following steps: the corresponding identifier of task in each classification is determined;Wherein, in classification, identifier is according to task ranking knot Fruit is incremented by successively by 1.
It should be understood that above-mentioned medium can be readable signal medium or readable storage medium storing program for executing.Readable storage medium Matter can be for example but not limited to: electricity, magnetic, optical, electromagnetic, infrared ray or semiconductor system, device or device, or it is any Above combination.The more specific example (non exhaustive list) of readable storage medium storing program for executing includes: to have one or more conducting wires Electrical connection, portable disc, hard disk, random access memory (RAM), read-only memory (ROM), erasable type may be programmed read-only storage Device (EPROM or flash memory), optical fiber, portable compact disc read only memory (CD-ROM), light storage device, magnetic memory device or The above-mentioned any appropriate combination of person.
Readable signal medium may include in a base band or as the data-signal that carrier wave a part is propagated, wherein carrying Readable program code.The data-signal of this propagation can take various forms, including but not limited to: electromagnetic signal, light letter Number or above-mentioned any appropriate combination.Readable signal medium can also be any readable medium other than readable storage medium storing program for executing, The readable medium can be sent, propagated or be transmitted for being used by instruction execution system, device or device or being tied with it Close the program used.
The program code for including on readable medium can transmit with any suitable medium, including but not limited to: wirelessly, have Line, optical cable, RF etc. or above-mentioned any appropriate combination.
Can with any combination of one or more programming languages come write for execute the disclosure operation program Code, described program design language include object oriented program language-Java, C++ etc., further include conventional Procedural programming language-such as " C " language or similar programming language.Program code can be fully in user It calculates and is executed in equipment, partially partially executes or remotely counted completely on a remote computing on the user computing device It calculates and is executed on equipment or server.In the situation for being related to remote computing device, remote computing device can pass through any kind Network --- be connected to user calculating equipment including local area network (LAN) or wide area network (WAN)-, or, it may be connected to it is outer Portion calculates equipment (such as connecting using ISP by internet).
Exemplary means
After the medium for describing disclosure illustrative embodiments, next, with reference to Fig. 4 to the exemplary reality of the disclosure The task execution device for applying mode is illustrated.
Referring to Fig. 4, Fig. 4 shows the structural frames of the task execution device according to one example embodiment of the disclosure Figure.As shown in figure 4, the task execution device of one example embodiment of the disclosure includes: classification of task unit 401, task ranking Unit 402 and task executing units 403, in which:
Classification of task unit 401, for being classified according to the duration that comes into force of task to task;
Task ranking unit 402, in each category, being ranked up according to the creation time of task to task;
Task executing units 403, for executing task according to the task ranking result in each classification.
As it can be seen that implementing the task execution device shown in Fig. 4, this can be executed in time when reaching the task entry-into-force time Business, to promote task execution efficiency, improves the usage experience of user;And occupancy for computer resource can be reduced, with Promote resource utilization.
As an alternative embodiment, classification of task unit 401 divides task according to the duration that comes into force of task The mode of class specifically:
If task is ranged target class by classification of task unit 401 there are task corresponding target category in existing classification Not;
If target category is not present in existing classification, classification of task unit 401 creates new category and ranges task newly Classification.
As it can be seen that implement the optional embodiment, task can be promoted by the poll simultaneously of the task under different classes of Execution efficiency.
As an alternative embodiment, task ranking unit 402 arranges task according to the creation time of task The mode of sequence specifically:
Task ranking unit 402 arranges task according to by the early time sequencing to evening according to the creation time of task Sequence.
As it can be seen that implementing the optional embodiment, it is only necessary to gradually inquire whether reach life according to the sequence of timed task The moment is imitated, without all timed tasks in the entire classification of poll every time, to promote the polling efficiency of task and appoint The execution efficiency of business.
As an alternative embodiment, the task execution device further includes scanning thread setting unit (not shown), Wherein:
Thread setting unit is scanned, for corresponding scanning thread to be arranged for each classification, to pass through scanning thread difference Scan the task in each classification.
As it can be seen that implement the optional embodiment, it can be by the way that multiple scanning threads be arranged, so that the wheel in of all categories It askes while carrying out, to promote the polling efficiency for task.
As an alternative embodiment, task executing units 403 are held according to the task ranking result in each classification The mode of row task specifically:
If the scanning the classification of thread Current Scan of the task does not meet the corresponding duration that comes into force, task executing units 403 According to coming into force, duration determines waiting time, to execute the task of Current Scan after waiting time;And
Task executing units 403 scan next task according to the task ranking result of the category.
Further, task executing units 403 determine the mode of waiting time according to the duration that comes into force specifically:
Task executing units 403 calculate Current Scan task creation time with come into force duration and, held as task The row time;
Task executing units 403 determine the time interval of task execution time and current time, as waiting time.
As it can be seen that implementing the optional embodiment, can still be existed by a poll it is determined that being immediately performed task The task is executed after preset duration, reduces the wrap count for task list, is reduced the waste for computer resource, is mentioned It is promoted to business execution efficiency.
As an alternative embodiment, the task execution device further includes identifier determination unit (not shown), In:
Identifier determination unit, for determining the corresponding identifier of task in each classification;Wherein, in classification, mark It is incremented by successively by 1 according to task ranking result to know symbol.
As it can be seen that implementing the optional embodiment, by determining corresponding identifier for task, arranged with clear its in task Position in table, and then corresponding thread of all categories can be made quickly to navigate to the task position for needing to scan when being scanned It sets, further improves polling efficiency.
Each functional module and above-mentioned task executing method due to the task execution device of the example embodiment of the disclosure Example embodiment the step of it is corresponding, therefore for those undisclosed details in the apparatus embodiments, please refer in the disclosure The embodiment for the task executing method stated.
It should be noted that although being referred to several modules or unit of task execution device in the above detailed description, It is that this division is not enforceable.In fact, according to embodiment of the present disclosure, two or more above-described modules or The feature and function of person's unit can embody in a module or unit.Conversely, an above-described module or The feature and function of unit can be to be embodied by multiple modules or unit with further division.
Example electronic device
After describing method, medium and the device of disclosure illustrative embodiments, next, introducing according to this public affairs The electronic equipment for the another exemplary embodiment opened.
Person of ordinary skill in the field it is understood that various aspects of the disclosure can be implemented as system, method or Program product.Therefore, various aspects of the disclosure can be with specific implementation is as follows, it may be assumed that complete hardware embodiment, complete The embodiment combined in terms of full Software Implementation (including firmware, microcode etc.) or hardware and software, can unite here Referred to as circuit, " module " or " system ".
The task execution device 500 of another optional example embodiment according to the disclosure is described referring to Fig. 5.Figure The task execution devices 500 of 5 displays are only an example, should not function to the embodiment of the present disclosure and use scope bring and appoint What is limited.
As shown in figure 5, task execution device 500 is showed in the form of electronic equipment.The component of task execution device 500 can To include but is not limited to: at least one above-mentioned processing unit 510, connects not homologous ray group at least one above-mentioned storage unit 520 The bus 530 of part (including storage unit 520 and processing unit 510).
Wherein, the storage unit is stored with program code, and said program code can be held by the processing unit 510 Row, so that the processing unit 510 executes described in the description section of this specification above-mentioned example method according to the disclosure The step of various illustrative embodiments.For example, the processing unit 510 can execute each step as shown in Figures 1 and 2 Suddenly.
Storage unit 520 may include the readable medium of volatile memory cell form, such as Random Access Storage Unit (RAM) 5201 and/or cache memory unit 5202, it can further include read-only memory unit (ROM) 5203.
Storage unit 520 can also include program/utility with one group of (at least one) program module 5205 5204, such program module 5205 includes but is not limited to: operating system, one or more application program, other program moulds It may include the realization of network environment in block and program data, each of these examples or certain combination.
Bus 530 can be to indicate one of a few class bus structures or a variety of, including storage unit bus or storage Cell controller, peripheral bus, graphics acceleration port, processing unit use any bus structures in a variety of bus structures Local bus.
Task execution device 500 can also (such as keyboard, sensing equipment, bluetooth be set with one or more external equipments 600 It is standby etc.) communication, the equipment interacted with task execution device 500 can be also enabled a user to one or more to be communicated, and/or with Enable the task execution device 500 with it is one or more of the other calculating equipment communicated any equipment (such as router, Modem etc.) communication.This communication can be carried out by input/output (I/O) interface 650.Also, task execution fills Set 500 can also by network adapter 560 and one or more network (such as local area network (LAN), wide area network (WAN) and/ Or public network, such as internet) communication.As shown in figure 5, network adapter 560 passes through bus 530 and task execution device 500 other modules communication.It should be understood that although not shown in the drawings, other hardware can be used in conjunction with task execution device 500 And/or software module, including but not limited to: microcode, device driver, redundant processing unit, external disk drive array, RAID system, tape drive and data backup storage system etc..
Through the above description of the embodiments, those skilled in the art is it can be readily appreciated that example described herein is implemented Mode can also be realized by software realization in such a way that software is in conjunction with necessary hardware.Therefore, according to the disclosure The technical solution of embodiment can be embodied in the form of software products, which can store non-volatile at one Property storage medium (can be CD-ROM, USB flash disk, mobile hard disk etc.) in or network on, including some instructions are so that a calculating Equipment (can be personal computer, server, terminal installation or network equipment etc.) is executed according to disclosure embodiment Method.
Although describing the spirit and principle of the disclosure by reference to several specific embodiments, it should be appreciated that, this It is open to be not limited to invented specific embodiment, the feature in these aspects cannot not to be meant that yet to the division of various aspects Combination is benefited to carry out, this to divide the convenience merely to statement.The disclosure be intended to cover appended claims spirit and Included various modifications and equivalent arrangements in range.

Claims (10)

1. a kind of task executing method characterized by comprising
Classified according to the duration that comes into force of task to the task;
In each category, the task is ranked up according to the creation time of the task;
The task is executed according to the task ranking result in each classification.
2. the method according to claim 1, wherein the duration that comes into force according to task divides the task Class, comprising:
If the task is ranged the target category there are the task corresponding target category in existing classification;
If the target category is not present in the existing classification, creates new category and the task is ranged into the new class Not.
3. the method according to claim 1, wherein being carried out according to the creation time of the task to the task Sequence, comprising:
The task is ranked up according to by the early time sequencing to evening according to the creation time of the task.
4. the method according to claim 1, wherein further include:
Corresponding scanning thread is set for each classification, scanned in each classification respectively by the scanning thread Task.
5. according to the method described in claim 4, it is characterized in that, being executed according to the task ranking result in each classification The task, comprising:
If the task of the classification of the scanning thread Current Scan does not meet the corresponding duration that comes into force, come into force according to Duration determines waiting time, to execute the task of the Current Scan after the waiting time;And
Next task is scanned according to the task ranking result of classification described in this.
6. according to the method described in claim 5, it is characterized in that, determining waiting time according to the duration that comes into force, comprising:
Calculate the task of the Current Scan creation time and the duration that comes into force and, as task execution time;
The time interval for determining the task execution time and current time, as waiting time.
7. the method according to claim 1, wherein further include:
Determine the corresponding identifier of task in each classification;Wherein, in the classification, the identifier is according to Task ranking result is incremented by successively by 1.
8. a kind of task execution device characterized by comprising
Classification of task unit, for being classified according to the duration that comes into force of task to the task;
Task ranking unit, in each category, being ranked up according to the creation time of the task to the task;
Task executing units, for executing the task according to the task ranking result in each classification.
9. a kind of computer readable storage medium, is stored thereon with computer program, which is characterized in that the computer program quilt Claim 1-7 described in any item methods are realized when processor executes.
10. a kind of electronic equipment characterized by comprising
Processor;And
Memory, for storing the executable instruction of the processor;
Wherein, the processor is configured to require 1-7 described in any item via executing the executable instruction and carry out perform claim Method.
CN201910726146.7A 2019-08-07 2019-08-07 Task executing method, device, electronic equipment and computer readable storage medium Pending CN110471752A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910726146.7A CN110471752A (en) 2019-08-07 2019-08-07 Task executing method, device, electronic equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910726146.7A CN110471752A (en) 2019-08-07 2019-08-07 Task executing method, device, electronic equipment and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN110471752A true CN110471752A (en) 2019-11-19

Family

ID=68510356

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910726146.7A Pending CN110471752A (en) 2019-08-07 2019-08-07 Task executing method, device, electronic equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN110471752A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111258728A (en) * 2020-01-09 2020-06-09 浙江大搜车软件技术有限公司 Task execution method and device, storage medium and electronic device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20010042090A1 (en) * 1998-05-28 2001-11-15 Roy H. Williams Thread based governor for time scheduled process application
CN1870767A (en) * 2005-12-14 2006-11-29 华为技术有限公司 Method for managing timer task
CN101964995A (en) * 2009-07-21 2011-02-02 中兴通讯股份有限公司 Method and device for updating uplink baseband chip parameters at NodeB side in WCDMA (Wideband Code Division Multiple Access) system
CN108647083A (en) * 2018-04-28 2018-10-12 北京京东金融科技控股有限公司 Task executing method, device, system, electronic equipment and computer-readable medium
CN108733462A (en) * 2017-04-18 2018-11-02 北京京东尚科信息技术有限公司 The method and apparatus of delay task

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20010042090A1 (en) * 1998-05-28 2001-11-15 Roy H. Williams Thread based governor for time scheduled process application
CN1870767A (en) * 2005-12-14 2006-11-29 华为技术有限公司 Method for managing timer task
CN101964995A (en) * 2009-07-21 2011-02-02 中兴通讯股份有限公司 Method and device for updating uplink baseband chip parameters at NodeB side in WCDMA (Wideband Code Division Multiple Access) system
CN108733462A (en) * 2017-04-18 2018-11-02 北京京东尚科信息技术有限公司 The method and apparatus of delay task
CN108647083A (en) * 2018-04-28 2018-10-12 北京京东金融科技控股有限公司 Task executing method, device, system, electronic equipment and computer-readable medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
裴鹏飞: "支持事务的分布式消息队列中间件的设计与实现", 《中国优秀硕士学位论文全文数据库 (信息科技辑)》 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111258728A (en) * 2020-01-09 2020-06-09 浙江大搜车软件技术有限公司 Task execution method and device, storage medium and electronic device

Similar Documents

Publication Publication Date Title
WO2022105589A1 (en) Resource scheduling method and apparatus, electronic device and computer readable medium
CN106331150B (en) For dispatching the method and apparatus of Cloud Server
CN108200134A (en) Request message management method and device, storage medium
WO2019153973A1 (en) Event driving method and device
CN111680124A (en) RPA-based large-scale customized customer demand obtaining and inquiring method
CN109685301A (en) Method for managing resource, device, equipment and readable storage medium storing program for executing
CN110785970B (en) Techniques to automate robotic creation of web pages
US20120254309A1 (en) Information processing apparatus and method, electronic device and control method thereof, and log collection system
CN110569298A (en) data docking and visualization method and system
CN112311868A (en) Message touch method and device and electronic equipment
CN103262498A (en) Behavior based client selection for disparate treatment
CN108170538A (en) A kind of information processing method, device and electronic equipment
CN108228363A (en) A kind of message method and device
CN109697537A (en) The method and apparatus of data audit
CN107944000A (en) Flight freight rate update method, device, electronic equipment, storage medium
CN110321252A (en) A kind of method and apparatus of craft services scheduling of resource
CN113205235B (en) Customer service scheduling method and device
CN105589877A (en) Information push method and application platform
CN116820714A (en) Scheduling method, device, equipment and storage medium of computing equipment
CN110297820A (en) A kind of data processing method, device, equipment and storage medium
CN110471752A (en) Task executing method, device, electronic equipment and computer readable storage medium
CN110442766A (en) Webpage data acquiring method, device, equipment and storage medium
CN112346628A (en) Special shared resource certificate management method, system and electronic equipment
CN107045452A (en) Dispatching method of virtual machine and device
CN116611749A (en) Intelligent electric power data input method and system based on micro-service architecture

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: 20191119

RJ01 Rejection of invention patent application after publication