A task processing method and device, electronic equipment and storage medium

By generating task processing queues and arrays, and processing task nodes in order of trigger time, the resource consumption and complexity issues of high-concurrency timed tasks are solved, and efficient task management is achieved.

CN115202841BActive Publication Date: 2026-02-27SHANGHAI BAIJIAYUN TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210804643.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-08
Publication Date
2026-02-27
Estimated Expiration
2042-07-08

AI Technical Summary

Technical Problem

Existing methods for handling high-concurrency timed tasks suffer from high algorithm complexity and high resource consumption, making it difficult to effectively manage a large number of timeout tasks.

Method used

By obtaining the trigger time and period of task nodes, a task processing queue and array are generated, tasks are processed in the order of trigger time, and the node arrangement order in the queue and array is updated, thereby reducing resource consumption and improving processing efficiency.

Benefits of technology

It reduces the resource consumption of high-concurrency scheduled tasks, improves data processing efficiency, and achieves low-complexity task management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115202841B_ABST
    Figure CN115202841B_ABST
Patent Text Reader

Abstract

The present disclosure provides a task processing method and device, electronic equipment and storage medium, by determining the trigger time and trigger period corresponding to the task node in the to-be-processed task; arranging the task nodes with the same trigger period in a vertical order according to the order of the trigger time to form a plurality of task processing queues, wherein the head node has the earliest trigger time; arranging the task processing queues in a horizontal order according to the order of the trigger time of the head node to generate a task processing array; processing the target head node that reaches the trigger time in time sequence, and determining the updated trigger time of the target head node; updating the arrangement order of the task nodes in the task processing queue corresponding to the target head node, and taking the task node with the earliest trigger time as the updated head node; repeating the step of processing the target head node that reaches the trigger time in time sequence until the preset task processing time limit is reached. The resource occupation ratio for processing large concurrent timing tasks can be reduced, and the data processing efficiency is high.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the technical field of data processing, and in particular, to a task processing method and device, an electronic device, and a storage medium. BACKGROUND

[0002] Large concurrent timing tasks are common in systems that require a large number of periodic tasks and systems with a large number of online users, such as the instant messaging field. In actual applications, there are often delayed tasks and timing tasks. In network connection scenarios, there are often some timeout controls, and as the number of connections increases, the number of these timeout tasks is often very large. Therefore, how to implement timeout management for a large number of tasks is a problem to be solved.

[0003] In the existing large concurrent timing task processing manner, a small top heap algorithm and a time wheel algorithm are usually used. To support large concurrent task quantities, the timing task often needs to meet requirements such as access complexity, resource occupation, and algorithm implementation complexity. However, the existing large concurrent timing task processing manner still has problems such as high algorithm complexity and large resource occupation. SUMMARY

[0004] The embodiments of the present disclosure at least provide a task processing method, device, electronic device, and storage medium, which can reduce the resource occupation ratio of processing large concurrent timing tasks, while the algorithm complexity is low, and the data processing efficiency is high.

[0005] The embodiments of the present disclosure provide a task processing method, which comprises:

[0006] obtaining a to-be-processed task comprising a plurality of task nodes, determining a trigger time and a trigger period corresponding to each task node;

[0007] arranging the task nodes with the same trigger period in sequence vertically according to the order of the trigger times, to generate a plurality of task processing queues, wherein the task node with the earliest trigger time is taken as a head node of the task processing queue;

[0008] arranging all the task processing queues in sequence horizontally according to the order of the trigger times corresponding to the head nodes, to generate a task processing array corresponding to the to-be-processed task;

[0009] processing a target head node reaching the trigger time in the task processing array in sequence according to the time sequence, and determining an updated trigger time corresponding to the target head node according to the trigger period corresponding to the target head node;

[0010] According to the update trigger time, update the arrangement order of the task node in the task processing queue corresponding to the target head node, and take the task node with the earliest trigger time in the updated task processing queue as the updated head node.

[0011] The step of sequentially processing the target head node in the task processing array that reaches the trigger time according to the time sequence is repeated until the preset task processing time limit corresponding to the to-be-processed task is reached.

[0012] In an optional implementation, the step of sequentially processing the target head node in the task processing array that reaches the trigger time according to the time sequence specifically includes:

[0013] Determining a current task processing time;

[0014] Traversing the head node in the task processing array that matches the current task processing time as the target head node;

[0015] Determining whether there is a parallel task node with the same trigger time as the target head node in the task processing queue corresponding to the target head node;

[0016] If there is, respectively executing the task matter corresponding to the target head node and the task matter corresponding to the parallel task node;

[0017] If there is not, executing the task matter corresponding to the target head node.

[0018] In an optional implementation, after the step of traversing the head node in the task processing array that matches the current task processing time as the target head node, the method further includes:

[0019] If there is no head node in the task processing array that matches the current task processing time, maintaining the arrangement order of the task processing array, and sequentially processing the next task processing time until there is the head node in the task processing array that matches the current task processing time.

[0020] In an optional implementation, after the step of sequentially arranging the task nodes with the same trigger period in the task processing array according to the sequence of the trigger time to generate a plurality of task processing queues, wherein the task node with the earliest trigger time is taken as the head node of the task processing queue, the method further includes:

[0021] Determining whether there is the task node with the same trigger time in the task processing queue;

[0022] If so, the task nodes with the same trigger time are arranged side by side in the corresponding order in the task processing queue.

[0023] In an optional implementation, after the arrangement order of the task nodes in the task processing queue corresponding to the target head node is updated according to the update trigger time and the task node with the earliest trigger time in the updated task processing queue is taken as the updated head node, the method further comprises:

[0024] determining whether the row where the updated head node is located in the task processing array is arranged in the order of the trigger times in sequence from front to back;

[0025] if so, maintaining the arrangement order between the task processing queues in the task processing array;

[0026] if not, updating the arrangement order between the task processing queues in the task processing array according to the order of the trigger times of the head nodes.

[0027] The embodiments of the present disclosure further provide a task processing device, which comprises:

[0028] a obtaining module configured to obtain to-be-processed tasks comprising a plurality of task nodes, determine a trigger time and a trigger period corresponding to each task node;

[0029] a task processing queue generating module configured to arrange the task nodes with the same trigger period in sequence from front to back according to the order of the trigger times, and generate a plurality of task processing queues, wherein the task node with the earliest trigger time is taken as a head node of the task processing queue;

[0030] a task processing array generating module configured to arrange all the task processing queues in sequence from left to right according to the order of the trigger times of the head nodes, and generate a task processing array corresponding to the to-be-processed tasks;

[0031] a task executing module configured to process target head nodes reaching the trigger time in the task processing array in sequence according to time sequence, determine an update trigger time corresponding to the target head node according to the trigger period of the target head node;

[0032] an updating module configured to update the arrangement order of the task nodes in the task processing queue corresponding to the target head node according to the update trigger time, and take the task node with the earliest trigger time in the updated task processing queue as the updated head node;

[0033] a circulating module, configured to repeat the step of sequentially processing the target head node in the task processing array which reaches the trigger time according to the time sequence until reaching a preset task processing time limit corresponding to the task to be processed.

[0034] In an optional implementation, the task execution module is specifically configured to:

[0035] determine a current task processing time;

[0036] traverse the head node in the task processing array which matches the current task processing time as the target head node;

[0037] determine whether there is a parallel task node with the same trigger time as the target head node in the task processing queue corresponding to the target head node;

[0038] if there is, respectively execute the task matter corresponding to the target head node and the task matter corresponding to the parallel task node;

[0039] if there is not, execute the task matter corresponding to the target head node.

[0040] In an optional implementation, the task execution module is further configured to:

[0041] if there is no head node in the task processing array which matches the current task processing time, maintain the arrangement order of the task processing array and perform the processing of the next task processing time according to the time sequence until there is the head node in the task processing array which matches the current task processing time.

[0042] In an optional implementation, the device further comprises a task processing array sorting module, and the task processing array sorting module is configured to:

[0043] determine whether the row where the updated head node is located in the task processing array is arranged in the order of the trigger time in sequence from left to right;

[0044] if yes, maintain the arrangement order between each task processing queue in the task processing array;

[0045] if no, update the arrangement order between each task processing queue in the task processing array according to the order of the trigger time corresponding to the head node.

[0046] The embodiment of the present disclosure further provides an electronic device, comprising a processor, a memory and a bus, the memory stores machine readable instructions executable by the processor, when the electronic device is running, the processor communicates with the memory through the bus, and the machine readable instructions are executed by the processor to perform the above task processing method or the steps in any possible implementation manner of the above task processing method.

[0047] The embodiment of the present disclosure further provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to perform the above task processing method or the steps in any possible implementation manner of the above task processing method.

[0048] The embodiment of the present disclosure further provides a computer program product, comprising a computer program / instruction, which is executed by a processor to implement the above task processing method or the steps in any possible implementation manner of the above task processing method.

[0049] The embodiment of the present disclosure provides a task processing method, device, electronic device and storage medium, by acquiring a to-be-processed task comprising a plurality of task nodes, determining a trigger time and a trigger period corresponding to each task node; according to the order of the trigger time, sequentially arranging task nodes with the same trigger period vertically to generate a plurality of task processing queues, wherein the task node with the earliest trigger time is taken as the head node of the task processing queue; according to the order of the trigger time corresponding to the head node, sequentially arranging all task processing queues horizontally to generate a task processing array corresponding to the to-be-processed task; sequentially processing target head nodes reaching the trigger time in the task processing array in time sequence; determining an updated trigger time corresponding to the target head node according to the trigger period corresponding to the target head node; updating the arrangement order of the task nodes in the task processing queue corresponding to the target head node according to the updated trigger time, and taking the task node with the earliest trigger time in the updated task processing queue as the updated head node; repeating the step of sequentially processing target head nodes reaching the trigger time in the task processing array in time sequence until a preset task processing time limit corresponding to the to-be-processed task is reached. The resource occupation ratio for processing large concurrent timing tasks can be reduced, the algorithm complexity is low, and the data processing efficiency is high.

[0050] In order to make the above-mentioned purposes, features and advantages of the present disclosure more obvious and easy to understand, the following preferred embodiments are specifically described below with reference to the accompanying drawings. BRIEF DESCRIPTION OF DRAWINGS

[0051] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following will briefly introduce the drawings needed to be used in the embodiments. The drawings incorporated into the specification and form a part of the specification, which show the embodiments consistent with the present disclosure, and are used to explain the technical solutions of the present disclosure together with the specification. It should be understood that the following drawings only show some of the embodiments of the present disclosure, and therefore should not be considered as a limitation to the scope, and for those skilled in the art, other related drawings can also be obtained without creative labor.

[0052] Figure 1 A flow chart of a task processing method provided by an embodiment of the present disclosure is shown;

[0053] Figure 2 An initial schematic diagram of a task processing array provided by an embodiment of the present disclosure is shown;

[0054] Figure 3 An updated schematic diagram of a task processing array provided by an embodiment of the present disclosure is shown;

[0055] Figure 4 A schematic diagram of a task processing device provided by an embodiment of the present disclosure is shown;

[0056] Figure 5 A schematic diagram of an electronic device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0057] In order to make the objects, technical solutions and advantages of the embodiments of the present disclosure clearer, the following will combine the drawings in the embodiments of the present disclosure to make a clear and complete description of the technical solutions in the embodiments of the present disclosure. Obviously, the described embodiments are only some of the embodiments of the present disclosure, but not all the embodiments. The components of the embodiments of the present disclosure described and shown in the drawings can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the claimed present disclosure, but only represents selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without creative labor are within the scope of the present disclosure.

[0058] It should be noted that: similar reference numerals and letters represent similar items in the following drawings, and therefore, once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.

[0059] The term "and / or", merely describes an associated relationship, which means that there can be three relationships, for example, A and / or B, which can represent: A exists alone, A and B exist together, and B exists alone. In addition, the term "at least one" herein means any one of a plurality or any combination of at least two of a plurality, for example, including at least one of A, B, and C, which means including any one or more elements selected from the set consisting of A, B, and C.

[0060] It is found through research that in the existing large concurrent timing task processing mode, a small top heap algorithm and a time wheel algorithm are usually used. In order to support a large concurrent task quantity, the timing task needs to meet various requirements such as access complexity requirement, resource occupation requirement, and algorithm implementation complexity. However, the existing large concurrent timing task processing mode still has problems of high algorithm complexity and large resource occupation.

[0061] Based on the above research, the present disclosure provides a task processing method and device, electronic equipment and storage medium. By obtaining a to-be-processed task including a plurality of task nodes, a trigger time and a trigger period corresponding to each task node are determined. According to the order of trigger time, task nodes with the same trigger period are arranged in sequence vertically to generate a plurality of task processing queues, wherein the task node with the earliest trigger time is used as the head node of the task processing queue. According to the order of trigger time corresponding to the head node, all task processing queues are arranged in sequence horizontally to generate a task processing array corresponding to the to-be-processed task. The target head node reaching the trigger time in the task processing array is processed in sequence according to the time sequence. The update trigger time corresponding to the target head node is determined according to the trigger period corresponding to the target head node. The arrangement order of the task nodes in the task processing queue corresponding to the target head node is updated according to the update trigger time, and the task node with the earliest trigger time in the updated task processing queue is used as the updated head node. The step of processing the target head node reaching the trigger time in the task processing array in sequence according to the time sequence is repeated until the preset task processing time limit corresponding to the to-be-processed task is reached. The resource occupation ratio for processing large concurrent timing tasks can be reduced, the algorithm complexity is low, and the data processing efficiency is high.

[0062] To facilitate the understanding of the present embodiment, first, a task processing method disclosed by the present embodiment is introduced in detail, the execution subject of the task processing method provided by the present embodiment is generally a computer device with certain computing capability, which for example includes a terminal device or a server or other processing device, and the terminal device can be a user equipment (User Equipment, UE), a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (Personal Digital Assistant, PDA), a handheld device, a computing device, a vehicle-mounted device, a wearable device, etc. In some possible implementation manners, the task processing method can be realized by a processor calling computer readable instructions stored in a memory.

[0063] Referring to Figure 1 FIG. 1 shows a flowchart of a task processing method provided by the present embodiment, and the method includes steps S101-S106, wherein:

[0064] S101, acquire a to-be-processed task including a plurality of task nodes, and determine a trigger time and a trigger period corresponding to each task node.

[0065] In a specific implementation, a to-be-processed task with a large concurrency is acquired, and the to-be-processed task includes a plurality of periodic task nodes that need to be executed, each of the task nodes has a corresponding trigger time and a trigger period, and the trigger time and the trigger period corresponding to each task node in the to-be-processed task are determined.

[0066] Here, the trigger time is a time point, which represents that a task node needs to execute a task item corresponding to the task node after reaching the time point, that is, a time point for triggering processing of the task node. Correspondingly, each task node in the to-be-processed task is periodically triggered, that is, for a task node, after triggering processing at the trigger time, the processing of the task node is triggered again after waiting for a trigger period.

[0067] It should be noted that the trigger time can be based on a time point for starting to process the to-be-processed task, for example, starting at 0s based on the time point for starting to process the to-be-processed task, and for a task node with a trigger time of 1s, all task nodes with a trigger time of 1s in the to-be-processed task need to be processed at 1s after starting to process the to-be-processed task. Further, for a task node with a trigger time of 1s, if the trigger period corresponding to the task node is 5s, the task node is triggered for processing at 1s after starting to process the to-be-processed task, and the next trigger time needs to be added by a trigger period, that is, 1s+5s=6s, that is, the task node is triggered for processing again at 6s after starting to process the to-be-processed task.

[0068] S102, according to the order of the trigger time, the task nodes with the same trigger period are arranged in sequence longitudinally to generate a plurality of task processing queues, wherein the task node with the earliest trigger time is used as the head node of the task processing queue.

[0069] In a specific implementation, in the to-be-processed tasks, the task nodes with the same trigger period are divided into a category, and for all the task nodes in each category, the task processing queue is formed by arranging in sequence longitudinally according to the order of the trigger time. In this way, in each task processing queue, all the task nodes have the same trigger period, and the task node with the earliest trigger time is used as the head node of the task processing queue.

[0070] It should be noted that the arrangement order of the task nodes in the task processing queue can be from bottom to top in sequence longitudinally according to the arrival order of the trigger time, or from top to bottom in sequence longitudinally according to the arrival order of the trigger time, which can be selected according to actual needs, and is not specifically limited here. For the task processing queue arranged from bottom to top in sequence longitudinally, the trigger time of the task node at the bottom of the task processing queue arrives earliest, and therefore the task node at the bottom of the task processing queue is the head node of the task processing queue. For the task processing queue arranged from top to bottom in sequence longitudinally, the trigger time of the task node at the top of the task processing queue arrives earliest, and therefore the task node at the top of the task processing queue is the head node of the task processing queue.

[0071] For example, for a task processing queue with a trigger period of 1s, the task node with a trigger time of 2s, the task node with a trigger time of 3s, the task node with a trigger time of 4s, and the task node with a trigger time of 5s are arranged in sequence longitudinally, wherein the task node with a trigger time of 2s is the head node of the task processing queue.

[0072] Further, if the task node with a certain trigger period is only one in the to-be-processed tasks, the corresponding task processing queue only contains this task node, and the task node is the head node of the task processing queue.

[0073] As a possible implementation, after step S102, the task processing method provided by the embodiment of the present disclosure can further include: determining whether there is a task node with the same trigger time in the task processing queue; if there is, the task nodes with the same trigger time are arranged side by side at the corresponding order in the task processing queue.

[0074] In a specific implementation, there can be multiple task nodes with the same trigger time and trigger period in the same task processing queue. For these task nodes, the task nodes with the same trigger time are arranged side by side at the order position of the trigger time of the task nodes in the task processing queue, so as to process the task nodes together in the process of triggering execution.

[0075] For example, for a task processing queue with a trigger period of 1s, the task processing queue includes a task node with a trigger time of 2s, two task nodes with a trigger time of 3s, and a task node with a trigger time of 4s. The task node with a trigger time of 2s is the head node of the task processing queue, and is arranged at the first position of the task processing queue. The two task nodes with a trigger time of 3s are arranged side by side at the second position of the task processing queue. The task node with a trigger time of 4s is arranged at the third position of the task processing queue.

[0076] S103, sequentially horizontally arrange all the task processing queues according to the order of the trigger time corresponding to the head node, to generate a task processing array corresponding to the to-be-processed task.

[0077] In a specific implementation, all the divided task processing queues are sequentially horizontally arranged according to the order of the trigger time corresponding to the head node in each task processing queue, to convert the to-be-processed task into a task processing array.

[0078] Specifically, referring to FIG. 1, Figure 2 FIG. 1 is an initial schematic diagram of a task processing array provided by an embodiment of the present disclosure. Figure 2 The task processing array shown in FIG. 1 is in an initial state, that is, at the time point of 0s as a starting time point for processing the to-be-processed task, the task processing array corresponding to the to-be-processed task, in which each box represents a task node, and the number in the box represents the corresponding trigger time.

[0079] It should be noted that, Figure 2 The schematic diagram of the task processing array shown in FIG. 1 is only a possibility of the task processing array, and does not limit the embodiments of the present disclosure.

[0080] For example, Figure 2As shown in the figure, the task processing array includes four task processing queues with trigger period of 1s, 5s, 10s and 30s respectively. For the task processing queue with trigger period of 1s, it includes 4 task nodes with trigger time of 1s; for the task processing queue with trigger period of 5s, it includes 1 task node with trigger time of 2s, 2 task nodes with trigger time of 4s and 2 task nodes with trigger time of 5s, and so on, the task processing queue with trigger period of 10s includes task nodes with trigger time of 2s, 3s, 6s, 9s and 10s respectively; the task processing queue with trigger period of 30s includes task nodes with trigger time of 20s and 25s respectively. The head node of the task processing queue with trigger period of 1s is the task node with trigger time of 1s; the head node of the task processing queue with trigger period of 5s is the task node with trigger time of 2s; the head node of the task processing queue with trigger period of 10s is the task node with trigger time of 2s; the head node of the task processing queue with trigger period of 30s is the task node with trigger time of 20s.

[0081] In this way, in the task processing array, the head nodes in each task processing queue are arranged in the row in the order of trigger time from small to large, and the task nodes in each task processing queue are arranged in the column in the order of trigger time from small to large.

[0082] S104, sequentially processing the target head nodes reaching the trigger time in the task processing array according to the time sequence; determining the updated trigger time corresponding to the target head node according to the trigger period corresponding to the target head node.

[0083] In the embodiment, the processing procedure for the to-be-processed tasks starts after the task processing array is constructed, and the specific processing procedure depends on the task processing array constructed in step S103. Since the head nodes in each task processing queue are arranged in the row in the order of trigger time from small to large in the task processing array, the trigger time corresponding to the row where the head nodes are located is the earliest in the task processing queue. Therefore, only the target head nodes reaching the trigger time in the row where the head nodes are located need to be checked sequentially after a preset checking period, and the processing of all target head nodes can complete the processing of all task nodes reaching the trigger time in the task processing array.

[0084] Here, the head nodes not reaching the trigger time are skipped.

[0085] It should be noted that the preset check period can be set according to the minimum unit of the trigger period corresponding to the task node in the to-be-processed task, which is not limited here, and preferably can be 1s, that is, at the time point of starting to process the to-be-processed task, 0s, 1s is checked whether there is a target head node with a trigger time of 1s in the row where the head node is located, 2s is checked whether there is a target head node with a trigger time of 2s in the row where the head node is located, and the like is sequentially inferred.

[0086] As a possible implementation, the process of the target head node reaching the trigger time in the time sequence processing task processing array can specifically include: determining a current task processing time; traversing the task processing array to match the head node corresponding to the current task processing time as the target head node; determining whether there is a parallel task node with the same trigger time as the target head node in the task processing queue corresponding to the target head node; if there is, respectively executing the task matter corresponding to the target head node and the task matter corresponding to the parallel task node; if not, executing the task matter corresponding to the target head node.

[0087] Here, the schematic diagram of the task processing array shown in Figure 2 The process of the target head node reaching the trigger time in the time sequence processing task processing array is described by taking the schematic diagram of the task processing array shown in the figure as an example. At the time point of processing the to-be-processed task, the head node of the task processing queue with a trigger period of 1s reaches the corresponding trigger time, that is, the target head node, and the head nodes of the remaining task processing queues do not reach the trigger time and do not process, so the task matter corresponding to the head node of the task processing queue with a trigger period of 1s is executed. However, the task processing queue with a trigger period of 1s includes multiple parallel task nodes with the same trigger time as the head node, that is, Figure 2 the task nodes with multiple trigger times at 1s in At this time, the task matters corresponding to all the task nodes with trigger times at 1s are processed, which is embodied in Figure 2 the figure, that is, all the task matters corresponding to the task processing queue with a trigger period of 1s are completed.

[0088] Further, after the task matter corresponding to the target head node is processed, the next trigger time of the target head node is changed, and the trigger time corresponding to the target head node is added to the corresponding trigger period to form the updated trigger time corresponding to the target head node.

[0089] It should be noted that for the parallel task nodes with the same trigger time as the target head node in the task processing queue corresponding to the target head node, the updated trigger time corresponding to the parallel task node is also determined according to the corresponding trigger period, that is, the trigger time corresponding to the parallel task node is added to the corresponding trigger period to form the updated trigger time corresponding to the parallel task node.

[0090] Here, also with Figure 2 Taking the schematic diagram of the task processing array as an example, when the time point for processing the task to be processed reaches 1s, after processing all task nodes in the task processing queue with a trigger period of 1s, it is necessary to add the trigger period to the trigger time of all task nodes in the task processing queue. That is, the trigger time corresponding to all task nodes in the task processing queue with a trigger period of 1s is updated to 1s + 1s = 2s.

[0091] S105. According to the update trigger time, update the arrangement order of the task nodes in the task processing queue corresponding to the target head node, and take the task node with the earliest trigger time in the updated task processing queue as the updated head node.

[0092] In practice, since the update trigger time is composed of the trigger time of the target head node plus the trigger period, the update trigger time may disrupt the order of the trigger times in the task processing queue. Therefore, it is necessary to rearrange the update trigger time corresponding to the target head node and the trigger times of the remaining task nodes in chronological order, and take the task node with the earliest trigger time after the update as the updated head node.

[0093] For details, please refer to Figure 3 The diagram shown is a schematic diagram of an update of a task processing array provided in an embodiment of this disclosure.

[0094] here, Figure 3 for Figure 2The initial schematic diagram of the task processing array is arranged in order and the trigger time is updated at the time point of processing the task to be processed. At 1s, the trigger time of all task nodes in the task processing queue with a trigger period of 1s is updated to 2s, and other task nodes are not triggered for processing and do not need to be updated in order. Therefore, when the time point of processing the task to be processed comes to 2s, the head nodes of the task processing queue with a trigger period of 1s, the task processing queue with a trigger period of 5s and the task processing queue with a trigger period of 10s all reach the trigger time, and the corresponding updated trigger times are 3s, 7s and 12s respectively. For the task processing queue with a trigger period of 5s, the updated trigger time 7s of the head node is greater than the trigger times of all other task nodes, so the task node with a trigger time of 7s is transferred to the end of the task processing queue, and the task node with the earliest trigger time 4s at this time is taken as the updated head node. Similarly, for the task processing queue with a trigger period of 10s, the updated trigger time 12s of the head node is greater than the trigger times of all other task nodes, so the task node with a trigger time of 12s is transferred to the end of the task processing queue, and the task node with the earliest trigger time 3s at this time is taken as the updated head node.

[0095] It should be noted that at this time, the trigger time of the head node of the task processing queue with a trigger period of 5s is 4s, and the trigger time of the head node of the task processing queue with a trigger period of 10s is 3s. This situation does not meet the requirement that the task processing array needs to be arranged in order according to the trigger times of the head nodes of the task processing queues. Therefore, the task processing queue with a trigger period of 5s and the task processing queue with a trigger period of 10s need to be transposed to maintain the requirement that the task processing array needs to be arranged in order according to the trigger times of the head nodes of the task processing queues.

[0096] Therefore, as a possible implementation, after step S105, the method further comprises: determining whether the row where the updated head node is located in the task processing array is arranged in order according to the trigger times of the head nodes of the task processing queues; if yes, maintaining the arrangement order of the task processing queues in the task processing array; if not, updating the arrangement order of the task processing queues in the task processing array according to the trigger times of the head nodes of the task processing queues.

[0097] S106, repeating the step of processing the target head node reaching the trigger time in the task processing array in order according to the time sequence until the preset task processing time limit corresponding to the task to be processed is reached.

[0098] In a specific implementation, steps S104-S105 are performed cyclically until a preset task processing time limit corresponding to the to-be-processed task is reached, and the processing of the to-be-processed task is completed.

[0099] Here, the preset task processing time limit can be determined according to the requirements of different to-be-processed tasks, and is not specifically limited here.

[0100] The task processing method provided in the embodiments of the present disclosure includes the following steps: obtaining a to-be-processed task including a plurality of task nodes, determining a trigger time and a trigger period corresponding to each task node; arranging task nodes with the same trigger period in sequence vertically according to the order of the trigger times, to generate a plurality of task processing queues, wherein a task node with the earliest trigger time is used as a head node of a task processing queue; arranging all the task processing queues in sequence horizontally according to the order of the trigger times corresponding to the head nodes, to generate a task processing array corresponding to the to-be-processed task; processing target head nodes reaching the trigger time in the task processing array in sequence according to the time sequence; determining an updated trigger time corresponding to the target head node according to the trigger period corresponding to the target head node; updating the arrangement order of the task nodes in the task processing queue corresponding to the target head node according to the updated trigger time, and using a task node with the earliest trigger time in the updated task processing queue as an updated head node; and repeating the step of processing target head nodes reaching the trigger time in the task processing array in sequence according to the time sequence until a preset task processing time limit corresponding to the to-be-processed task is reached. The resource occupation ratio for processing large concurrent timing tasks can be reduced, the algorithm complexity is low, and the data processing efficiency is high.

[0101] Those skilled in the art can understand that, in the above method of the specific implementation, the writing order of each step does not mean a strict execution order and does not constitute any limitation on the implementation process, and the specific execution order of each step should be determined according to its function and possible internal logic.

[0102] Based on the same inventive concept, the embodiments of the present disclosure also provide a task processing device corresponding to the task processing method. Since the principle of solving problems by the device in the embodiments of the present disclosure is similar to the above-mentioned task processing method, the implementation of the device can be referred to the implementation of the method, and the repeated parts will not be described here.

[0103] Please refer to Figure 4 A structural schematic diagram of a task processing device 400 provided in the embodiments of the present disclosure is shown in FIG. 4. As shown in FIG. 4, the task processing device 400 provided in the embodiments of the present disclosure includes the following modules. Figure 4

[0104] The obtaining module 410 is configured to obtain a to-be-processed task including a plurality of task nodes, and determine a trigger time and a trigger period corresponding to each task node. ​

[0105] The task processing queue generation module 420 is configured to arrange the task nodes with the same trigger period in sequence according to the order of the trigger time, and generate a plurality of task processing queues, wherein the task node with the earliest trigger time is used as a head node of the task processing queue.

[0106] The task processing array generation module 430 is configured to arrange all the task processing queues in sequence according to the order of the trigger time corresponding to the head node, and generate a task processing array corresponding to the task to be processed.

[0107] The task execution module 440 is configured to sequentially process a target head node reaching the trigger time in the task processing array in time sequence, and determine an updated trigger time corresponding to the target head node according to the trigger period corresponding to the target head node.

[0108] The update module 450 is configured to update the arrangement order of the task nodes in the task processing queue corresponding to the target head node according to the updated trigger time, and use the task node with the earliest trigger time in the updated task processing queue as an updated head node.

[0109] The cycle module 460 is configured to repeat the step of sequentially processing the target head node reaching the trigger time in the task processing array in time sequence until a preset task processing time limit corresponding to the task to be processed is reached.

[0110] The description of the processing flow of each module in the device and the interaction flow between the modules can refer to the related description in the above method embodiments, and will not be described in detail here.

[0111] The task processing device provided by the embodiment of the present disclosure comprises: obtaining a to-be-processed task comprising a plurality of task nodes; determining a trigger time and a trigger period corresponding to each task node; arranging the task nodes with the same trigger period in sequence vertically according to the order of the trigger times to generate a plurality of task processing queues, wherein the task node with the earliest trigger time is used as a head node of the task processing queue; arranging all the task processing queues in sequence horizontally according to the order of the trigger times corresponding to the head nodes to generate a task processing array corresponding to the to-be-processed task; processing the target head nodes reaching the trigger time in the task processing array in sequence according to the time sequence; determining an updated trigger time corresponding to the target head node according to the trigger period corresponding to the target head node; updating the arrangement order of the task nodes in the task processing queue corresponding to the target head node according to the updated trigger time, and using the task node with the earliest trigger time in the updated task processing queue as an updated head node; repeating the step of processing the target head nodes reaching the trigger time in the task processing array in sequence according to the time sequence until a preset task processing time limit corresponding to the to-be-processed task is reached. The resource occupation ratio for processing large concurrent timing tasks can be reduced, the algorithm complexity is low, and the data processing efficiency is high.

[0112] Corresponding to Figure 1 the task processing method, the embodiment of the present disclosure also provides an electronic device 500, as shown in Figure 5 a structural schematic diagram of the electronic device 500 provided by the embodiment of the present disclosure, comprising:

[0113] a processor 51, a memory 52, and a bus 53; the memory 52 is used for storing execution instructions, comprising an internal memory 521 and an external memory 522; the internal memory 521 is also called an internal storage, and is used for temporarily storing operation data in the processor 51 and data exchanged with the external memory 522 such as a hard disk; the processor 51 exchanges data with the external memory 522 through the internal memory 521; when the electronic device 500 is running, the processor 51 and the memory 52 communicate through the bus 53, so that the processor 51 executes Figure 1 the steps of the task processing method.

[0114] The embodiment of the present disclosure also provides a computer readable storage medium, which stores a computer program, and the computer program is run by a processor to execute the steps of the task processing method described in the above method embodiment. The storage medium can be a volatile or non-volatile computer readable storage medium.

[0115] The embodiment of the present disclosure further provides a computer program product, which comprises computer instructions, and the computer instructions can execute the steps of the task processing method described in the above method embodiment when executed by a processor. Details can be referred to the above method embodiment, and will not be described here.

[0116] The computer program product can be implemented by hardware, software or a combination thereof. In an optional embodiment, the computer program product is embodied as a computer storage medium. In another optional embodiment, the computer program product is embodied as a software product, such as a software development kit (SDK) or the like.

[0117] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described device can refer to the corresponding process in the foregoing method embodiment, and will not be described here. In several embodiments provided by the present disclosure, it should be understood that the disclosed device and method can be implemented by other means. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division, and actual implementation can have another division manner. For another example, a plurality of units or components can be combined or integrated into another system, or some features can be omitted or not executed. In addition, the coupling or direct coupling or communication connection between the units or components shown or discussed can be indirect coupling or communication connection through some communication interface, device or unit, which can be electrical, mechanical or other forms.

[0118] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, that is, they can be located in one place or distributed on a plurality of network units. According to actual needs, part or all of the units can be selected to achieve the purpose of the embodiment.

[0119] In addition, each functional unit in each embodiment of the present disclosure can be integrated in one processing unit, or each unit can exist physically, or two or more units can be integrated in one unit.

[0120] If the functions are implemented in the form of software function units and sold or used as independent products, they can be stored in a nonvolatile computer readable storage medium executable by a processor. Based on this understanding, the technical solutions of the present disclosure essentially or the part that contributes to the prior art or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present disclosure. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (Read-Only Memory, ROM), a random access memory (Random Access Memory, RAM), a magnetic disk or an optical disk, and various media that can store program codes.

[0121] Finally, it should be noted that: the above-described embodiments are only specific embodiments of the present disclosure, used to illustrate the technical solutions of the present disclosure, and not to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art who is familiar with the technology in the art can still make modifications or easily think of changes to the technical solutions described in the foregoing embodiments, or make equivalent replacements to some of the technical features; and these modifications, changes or replacements do not cause the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be covered within the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be subject to the protection scope of the claims.

Claims

1. A task processing method, characterized in that, include: Obtain the tasks to be processed, which include multiple task nodes, and determine the trigger time and trigger period for each task node; Based on the order of the trigger times, the task nodes with the same trigger period are arranged vertically in sequence to generate multiple task processing queues, wherein the task node with the earliest trigger time is the head node of the task processing queue. Based on the order of the trigger times corresponding to the head nodes, all the task processing queues are arranged horizontally in sequence to generate the task processing array corresponding to the task to be processed. The target head nodes in the task processing array that arrive at the trigger time are processed sequentially according to the time sequence; the update trigger time corresponding to the target head node is determined according to the trigger period corresponding to the target head node; Based on the update trigger time, update the order of the task nodes in the task processing queue corresponding to the target head node, and take the task node with the earliest trigger time in the updated task processing queue as the updated head node; Determine whether the row containing the updated head node in the task processing array is arranged horizontally in chronological order according to the corresponding trigger times; if so, maintain the arrangement order between the task processing queues in the task processing array; if not, update the arrangement order between the task processing queues in the task processing array according to the chronological order of the trigger times corresponding to the head nodes. Repeat the steps of processing the target head nodes in the task processing array that have reached the trigger time in sequence until the preset task processing time limit corresponding to the task to be processed is reached.

2. The method according to claim 1, characterized in that, The step of processing the target head nodes in the task processing array that arrive at the trigger time in a sequential manner specifically includes: Determine the current task processing time; Traverse the task processing array and take the head node that matches the current task processing time as the target head node; Determine whether there is a parallel task node with the same trigger time as the target head node in the task processing queue corresponding to the target head node; If they exist, then execute the task items corresponding to the target head node and the task items corresponding to the parallel task node respectively; If it does not exist, then execute the task item corresponding to the target head node.

3. The method according to claim 2, characterized in that, After traversing the task processing array and selecting the head node that matches the current task processing time as the target head node, the method further includes: If there is no head node in the task processing array that matches the current task processing time, the arrangement order of the task processing array is maintained, and the next task processing time is processed according to the time sequence until there is a head node in the task processing array that matches the current task processing time.

4. The method according to claim 1, characterized in that, After the step of sequentially arranging task nodes with the same triggering period vertically according to the order of the triggering time to generate multiple task processing queues, wherein the task node with the earliest triggering time serves as the head node of the task processing queue, the method further includes: Determine whether there are any task nodes with the same trigger time in the task processing queue; If they exist, the task nodes with the same trigger time will be set up side by side in the corresponding order in the task processing queue.

5. A task processing device, characterized in that, include: The acquisition module is used to acquire tasks to be processed, including multiple task nodes, and determine the trigger time and trigger period corresponding to each task node. The task processing queue generation module is used to arrange the task nodes with the same triggering period vertically in sequence according to the order of the triggering time to generate multiple task processing queues, wherein the task node with the earliest triggering time is used as the head node of the task processing queue. The task processing array generation module is used to arrange all the task processing queues horizontally in sequence according to the order of the trigger times corresponding to the head nodes, so as to generate the task processing array corresponding to the task to be processed. The task execution module is used to process the target head nodes in the task processing array that arrive at the trigger time in a sequential manner according to the time sequence; and to determine the update trigger time corresponding to the target head node according to the trigger period corresponding to the target head node. The update module is used to update the order of the task nodes in the task processing queue corresponding to the target head node according to the update trigger time, and to take the task node with the earliest trigger time in the updated task processing queue as the updated head node. The loop module is used to repeat the step of processing the target head node in the task processing array that reaches the trigger time in sequence according to the time order until the preset task processing time limit corresponding to the task to be processed is reached. The device is further configured to determine whether the row containing the updated head node in the task processing array is arranged horizontally in chronological order according to the corresponding trigger times; if so, maintain the arrangement order between the various task processing queues in the task processing array; if not, update the arrangement order between the various task processing queues in the task processing array according to the chronological order of the trigger times corresponding to the head nodes.

6. The apparatus according to claim 5, characterized in that, The task execution module is specifically used for: Determine the current task processing time; Traverse the task processing array and take the head node that matches the current task processing time as the target head node; Determine whether there is a parallel task node with the same trigger time as the target head node in the task processing queue corresponding to the target head node; If they exist, then execute the task items corresponding to the target head node and the task items corresponding to the parallel task node respectively; If it does not exist, then execute the task item corresponding to the target head node.

7. The apparatus according to claim 6, characterized in that, The task execution module is also used for: If there is no head node in the task processing array that matches the current task processing time, the arrangement order of the task processing array is maintained, and the next task processing time is processed according to the time sequence until there is a head node in the task processing array that matches the current task processing time.

8. An electronic device, characterized in that, include: The device includes a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus. When the machine-readable instructions are executed by the processor, they perform the steps of the task processing method as described in any one of claims 1 to 4.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of the task processing method as described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Universal timed task management realization method

    CN102129393A

  • Cluster-task processing method and device

    CN106844043A