Scheduled task processing method and related equipment
By obtaining the task configuration table and establishing a trigger timetable, and determining the target thread processing timing task set, the problem of low efficiency in traditional timing task processing is solved and more efficient task processing is achieved.
Patent Information
- Application Number
- CN202011295062.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-18
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2040-11-18
AI Technical Summary
Traditional timing task processing methods are inefficient and cannot effectively handle a large number of regular and periodic operations, resulting in a reduction in processing efficiency.
By obtaining the task configuration table, determining N timing task sets and establishing a trigger timetable, determining the earliest trigger time, determining the target thread based on the preset thread configuration table, processing the target timing task set, improving processing efficiency.
The processing efficiency of timing tasks is improved, the inefficiency problem of single task processing is avoided, and the overall performance of the system is improved through multi-threading.
Smart Images

Figure CN112433833B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of electronic technology, and in particular to a timed task processing method and related equipment. Background Art
[0002] In Internet companies, each WEB application system performs related regular operations. In the industry, such regular and periodic operations are defined as scheduled tasks. With the continuous increase in application services, the number of scheduled tasks is also increasing. In traditional scheduled task processing, scheduled tasks are processed individually, which reduces the efficiency of processing scheduled tasks. Summary of the invention
[0003] The embodiments of the present application provide a scheduled task processing method and related equipment, which are beneficial to improving the efficiency of processing scheduled tasks.
[0004] In a first aspect, an embodiment of the present application provides a scheduled task processing method, which is applied to an electronic device, and the method includes:
[0005] Triggering a first acquisition instruction, where the first acquisition instruction is used to instruct to acquire a task configuration table from a first database;
[0006] Determine N scheduled task sets based on the task configuration table, where N is a positive integer;
[0007] Establishing a trigger schedule based on the N scheduled task sets, and storing the N scheduled task sets in a second database, wherein the trigger schedule includes N trigger moments, and the N scheduled task sets correspond one-to-one to the N trigger moments;
[0008] Determine the earliest trigger time in the trigger time table as the first trigger time, and trigger a second acquisition instruction at the first trigger time, the second acquisition instruction is used to instruct to acquire the target scheduled task set corresponding to the first trigger time, and the trigger times in the trigger time table are all later than the trigger time of the first acquisition instruction;
[0009] Based on the target scheduled task set and a preset thread configuration table, determining a target thread for processing the target scheduled task set;
[0010] The target thread is used to process the target scheduled task set; the first trigger time is deleted from the trigger time table until all the trigger times in the trigger time table are defined as the first trigger time.
[0011] In a second aspect, an embodiment of the present application provides a scheduled task processing device, the device comprising:
[0012] A first triggering unit, used to trigger a first acquisition instruction, where the first acquisition instruction is used to instruct to acquire a task configuration table from a first database;
[0013] A first determining unit, configured to determine N scheduled task sets based on the task configuration table, wherein N is a positive integer;
[0014] An establishing unit, configured to establish a trigger schedule based on the N scheduled task sets, and store the N scheduled task sets in a second database, wherein the trigger schedule includes N trigger moments, and the N scheduled task sets correspond one-to-one to the N trigger moments;
[0015] A second trigger unit is used to determine the earliest trigger time in the trigger time table as the first trigger time, and trigger a second acquisition instruction at the first trigger time, wherein the second acquisition instruction is used to instruct to acquire a target scheduled task set corresponding to the first trigger time, and the trigger times in the trigger time table are all later than the trigger time of the first acquisition instruction;
[0016] A second determining unit, configured to determine a target thread for processing the target scheduled task set based on the target scheduled task set and a preset thread configuration table;
[0017] A processing unit is used to process the target scheduled task set using the target thread; and to delete the first trigger time in the trigger time table until all the trigger times in the trigger time table are defined as the first trigger time.
[0018] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the program includes instructions for executing the steps in the method described in the first aspect of the embodiment of the present application.
[0019] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program for electronic data exchange, wherein the computer program enables a computer to execute part or all of the steps described in the method described in the first aspect of the embodiment of the present application.
[0020] In a fifth aspect, an embodiment of the present application provides a computer program product, wherein the computer program product includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute some or all of the steps described in the method described in the first aspect of the embodiment of the present application. The computer program product may be a software installation package.
[0021] It can be seen that in the embodiment of the present application, the electronic device first triggers the first acquisition instruction, the first acquisition instruction is used to instruct to obtain the task configuration table from the first database; then, based on the task configuration table, N scheduled task sets are determined, and then a trigger schedule is established based on the N scheduled task sets, and the N scheduled task sets are stored in the second database, and then the earliest trigger moment in the trigger schedule is determined as the first trigger moment, and the second acquisition instruction is triggered at the first trigger moment, the second acquisition instruction is used to indicate to obtain the target scheduled task set corresponding to the first trigger moment, and then based on the target scheduled task set and the preset thread configuration table, the target thread for processing the target scheduled task set is determined, and finally the target thread is used to process the target scheduled task set. Since the electronic device determines the target thread for processing the scheduled tasks in the target scheduled task set through the preset thread configuration table, and uses the target thread to process the target scheduled task set, rather than processing a single scheduled task, it is beneficial to improve the processing efficiency of the scheduled tasks. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0023] Figure 1 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application;
[0024] Figure 2 It is a flowchart of a scheduled task processing method provided in an embodiment of the present application;
[0025] Figure 3 A schematic diagram of the structure of another electronic device provided in an embodiment of the present application;
[0026] Figure 4 A schematic diagram of the structure of a scheduled task processing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0027] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0028] The following are detailed descriptions of each.
[0029] The terms "first", "second", "third" and "fourth" etc. in the specification and claims of the present application and the drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.
[0030] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0031] Below, some terms in this application are explained to facilitate understanding by those skilled in the art.
[0032] Electronic devices may include various handheld devices, vehicle-mounted devices, wearable devices, computing devices or other processing devices connected to a wireless modem with wireless communication functions, as well as various forms of user equipment (UE), mobile stations (MS), terminal devices, etc.
[0033] like Figure 1 As shown, Figure 1 1 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device includes a processor, a memory, a signal processor, a transceiver, a display screen, a speaker, a communication interface, a random access memory (RAM), a camera, a sensor, and the like. Among them, the memory, the signal processor, the display screen, the speaker, the RAM, the camera, the sensor, and the communication interface are connected to the processor, and the transceiver is connected to the signal processor.
[0034] The display screen may be a liquid crystal display (LCD), an organic or inorganic light-emitting diode (OLED), an active matrix organic light-emitting diode panel (AMOLED), etc.
[0035] The camera may be a common camera, an infrared camera, or a smart camera, which is not limited here. The camera may be a front camera or a rear camera, which is not limited here.
[0036] Among them, the sensor includes at least one of the following: a light sensor, a gyroscope, an infrared proximity sensor, a fingerprint sensor, a pressure sensor, and the like. Among them, the light sensor, also known as an ambient light sensor, is used to detect the brightness of ambient light. The light sensor may include a photosensitive element and an analog-to-digital converter. Among them, the photosensitive element is used to convert the collected light signal into an electrical signal, and the analog-to-digital converter is used to convert the above electrical signal into a digital signal. Optionally, the light sensor may also include a signal amplifier, which may amplify the electrical signal converted by the photosensitive element and output it to the analog-to-digital converter. The above-mentioned photosensitive element may include at least one of a photodiode, a phototransistor, a photoresistor, and a silicon photocell.
[0037] Among them, the processor is the control center of the electronic device, which uses various interfaces and lines to connect the various parts of the entire electronic device, and performs various functions of the electronic device and processes data by running or executing software programs and / or modules stored in the memory, and calling data stored in the memory, thereby monitoring the electronic device as a whole.
[0038] The processor may integrate an application processor and a modem processor, wherein the application processor mainly processes an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the modem processor may not be integrated into the processor.
[0039] The memory is used to store software programs and / or modules, and the processor executes various functional applications and data processing of the electronic device by running the software programs and / or modules stored in the memory. The memory may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, a software program required for at least one function, etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0040] The embodiments of the present application are described in detail below.
[0041] like Figure 2 As shown, a timed task processing method provided in an embodiment of the present application is applied to the above electronic device, and specifically includes the following steps:
[0042] Step 201: triggering a first acquisition instruction, wherein the first acquisition instruction is used to instruct to acquire a task configuration table from a first database.
[0043] Wherein, the first acquisition instruction is triggered regularly at a preset time.
[0044] The task configuration table includes the scheduled tasks to be executed the next day and the execution time of the scheduled tasks. The scheduled tasks to be executed may be one or more.
[0045] Optionally, the first acquisition instruction carries identification information of the scheduled task, and the scheduled task configuration table is acquired from the first database based on the identification information of the scheduled task.
[0046] The scheduled tasks included in the task configuration table may belong to different task types.
[0047] Among them, the same scheduled task in the task configuration table may need to be executed multiple times.
[0048] The acquisition instruction may occupy 1 byte, and if the first acquisition instruction is 1, the task configuration table is acquired from the database, or if the first acquisition instruction is 0, the task configuration table is acquired from the database.
[0049] Step 202: Determine N scheduled task sets based on the task configuration table, where N is a positive integer.
[0050] The scheduled tasks in the scheduled task set may belong to the same task type or may not belong to the same service type.
[0051] The execution times of the scheduled tasks included in the scheduled task set may be the same or different.
[0052] The first database and the second database are different databases.
[0053] The N scheduled task sets include all scheduled tasks in the task configuration table.
[0054] Step 203: Establish a trigger schedule based on the N scheduled task sets, and store the N scheduled task sets in a second database, wherein the trigger schedule includes N trigger moments, and the N scheduled task sets correspond one-to-one to the N trigger moments.
[0055] Among them, different scheduled task sets have different processing times, and different scheduled task sets are obtained at different triggering moments.
[0056] The triggering time is earlier than the execution time of the corresponding scheduled task in the scheduled task set.
[0057] Step 204: Determine the earliest trigger time in the trigger schedule as the first trigger time, and trigger a second acquisition instruction at the first trigger time, wherein the second acquisition instruction is used to indicate the acquisition of the target scheduled task set corresponding to the first trigger time, and the trigger times in the trigger schedule are all later than the trigger time of the first acquisition instruction.
[0058] Among them, the target scheduled task sets obtained at different first triggering moments are different.
[0059] The processing methods for different target scheduled task sets are the same.
[0060] Step 205: Based on the target scheduled task set and a preset thread configuration table, determine a target thread for processing the target scheduled task set.
[0061] The preset thread table includes relevant information of at least one thread.
[0062] Optionally, the relevant information of the thread may be a success rate of tasks processed by the thread, an average time of tasks processed by the thread, a type of tasks processed by the thread, and so on.
[0063] Step 206: Use the target thread to process the target scheduled task set.
[0064] The target thread may be one or more than one target thread.
[0065] Wherein, when there are multiple target threads, there is a one-to-one correspondence between the target threads and the scheduled tasks in the target scheduled task set, and the target threads are used to process the corresponding scheduled tasks.
[0066] It can be seen that in the embodiment of the present application, the electronic device first triggers the first acquisition instruction, the first acquisition instruction is used to instruct to obtain the task configuration table from the first database; then, based on the task configuration table, N scheduled task sets are determined, and then a trigger schedule is established based on the N scheduled task sets, and the N scheduled task sets are stored in the second database, and then the earliest trigger moment in the trigger schedule is determined as the first trigger moment, and the second acquisition instruction is triggered at the first trigger moment, the second acquisition instruction is used to indicate to obtain the target scheduled task set corresponding to the first trigger moment, and then based on the target scheduled task set and the preset thread configuration table, the target thread for processing the target scheduled task set is determined, and finally the target thread is used to process the target scheduled task set. Since the electronic device determines the target thread for processing the scheduled tasks in the target scheduled task set through the preset thread configuration table, and uses the target thread to process the target scheduled task set, rather than processing a single scheduled task, it is beneficial to improve the processing efficiency of the scheduled tasks.
[0067] In an implementation of the present application, the task configuration table includes S first scheduled tasks to be executed and T first task execution times, and each of the first scheduled tasks to be executed corresponds to at least one first task execution time;
[0068] The determining N scheduled task sets based on the task configuration table includes:
[0069] Determining the earliest first task execution time and the latest first task execution time among the T first task execution times;
[0070] Based on the earliest first task execution time, the latest first task execution time and a first preset duration, determining N first time periods, where the duration of the first time period is less than or equal to the first preset duration;
[0071] Based on the N first time periods, the S first scheduled tasks to be executed and the T first task execution times, the N scheduled task sets are determined, the N first time periods and the N scheduled task sets correspond one to one, and the first task execution time of the first scheduled task to be executed included in each scheduled task set is within the same time period.
[0072] Among them, the S first scheduled tasks to be executed are all scheduled tasks that need to be executed the next day.
[0073] The first task execution time is the execution time of the first scheduled task to be executed.
[0074] Each first scheduled task to be executed may need to be executed once or multiple times.
[0075] Among them, each first task execution time among the T first task execution times is different.
[0076] Among them, different first scheduled tasks to be executed may correspond to the same first task execution time, or different first scheduled tasks to be executed may correspond to different first task execution times.
[0077] The first preset duration may be 30 seconds, 2 minutes, 30 minutes, and so on.
[0078] Among them, if the time difference between the earliest first task execution time and the latest first task execution time is equal to the sum of N first preset durations, then the durations of the N first time periods are all equal to the first preset durations, and if the time difference between the earliest first task execution time and the latest first task execution time is greater than the sum of N first preset durations, then the duration of the first time period where the latest first task execution time is located is less than the first preset duration. Among them, the scheduled task set may include at least one first task execution time of the same first scheduled task to be executed.
[0079] The same first scheduled task to be executed may belong to at least one scheduled task set.
[0080] For example, the task configuration table includes 4 tasks (A, B, C and D) and the execution time of each task, wherein the execution time of task A includes 08:20:30, 08:30:40 and 10:45:20, the execution time of task B includes 10:20:30, 11:30:40 and 11:45:20, the execution time of task C includes 08:22:30, 09:45:40 and 10:45:20, and the execution time of task D includes 09:21:30, 08:32:40 and 11:45:22. Assuming that the first preset duration is 1 hour, since the earliest execution time is 08:20:30 and the latest execution time is 11:45:22, 4 time periods (time period 1, time period 2, time period 3 and time period 4) can be determined, among which time period 1 is 08:20:30-09:20:30, time period 2 is 09:20:31-10:20:31, time period 3 is 10:20:32-11:20:32 and time period 4 is 11:20:33-12:20:33. Therefore, it can be determined that the scheduled task set corresponding to time period 1 is (task A, task C, task D), the scheduled task set corresponding to time period 2 is (task B, task C and task D), the scheduled task set corresponding to time period 3 is (task A, task C), and the scheduled task set corresponding to time period 4 is (task B, task D).
[0081] It can be seen that in the embodiment of the present application, determining N scheduled task sets based on the task configuration table is beneficial to executing multiple scheduled tasks in different scheduled task sets in different time periods, which is beneficial to improving the processing efficiency of scheduled tasks.
[0082] In an implementation of the present application, the preset thread configuration table includes at least one thread and a success rate of each thread executing a task, the task configuration table also includes the importance of each first scheduled task to be executed, the target scheduled task set includes at least one first scheduled task to be executed, and the number of first scheduled tasks to be executed included in the target scheduled task set is less than or equal to S;
[0083] The step of determining a target thread for processing the target scheduled task set based on the target scheduled task set and a preset thread configuration table includes:
[0084] Sorting the at least one thread according to a descending order of success rate to obtain a thread subset;
[0085] Sorting the at least one first scheduled task to be executed included in the target scheduled task set based on a descending order of importance to obtain a first subset of scheduled tasks to be executed;
[0086] Based on a first allocation principle, the first to-be-executed scheduled task in the first to-be-executed scheduled task subset is assigned to a thread in the thread subset for processing, and the thread processing the first to-be-executed scheduled task is determined to be the target thread. The first allocation principle is that the position of the thread processing the first to-be-executed scheduled task in the thread subset is the same as the position of the first to-be-executed scheduled task in the first to-be-executed scheduled task subset.
[0087] The importance is preset, and the importance of the first scheduled task to be executed may be the same or different. The greater the importance, the more important the first scheduled task to be executed.
[0088] The success rate of a thread executing a task is the ratio of the number of tasks successfully executed by the thread to the number of tasks that the task thread has executed. Therefore, the success rate of a thread executing a task changes as the number of tasks executed by the thread increases.
[0089] Optionally, if the number of threads included in the thread subset is less than the number of first scheduled tasks to be executed in the first scheduled task subset to be executed, a new thread is created to process the first scheduled task to be executed to which no thread is allocated.
[0090] If the scheduled task executed by the thread may have multiple execution times, the scheduled task is executed at multiple times.
[0091] For example, if thread 1 processes the first scheduled task A to be executed, and A has three first task execution times (a, b, and c), thread 1 processes A at the first task execution time a, the first task execution time b, and the first task execution time c respectively.
[0092] For example, the preset thread configuration table includes 5 threads (#1, #2, #3, #4 and #5), wherein the success rate of #1 is 90%, the success rate of #2 is 95%, the success rate of #3 is 78%, the success rate of #4 is 75% and the success rate of #5 is 70%, and the target scheduled task set includes 3 first scheduled tasks to be executed (task A, task B and task C), wherein the importance of task A is level 3, the importance of task B is level 1 and the importance of C is level 2. After sorting the threads from high to low based on the success rate, the obtained thread subset is (#2, #1, #3, #4 and #5), and after sorting the scheduled tasks from high to low based on the importance, the obtained first scheduled task subset to be executed is (task A, task C and task B), then thread #2 is used to process task A, thread 31 is used to process task C and thread #3 is used to process task B.
[0093] It can be seen that in the embodiment of the present application, determining the thread that executes the first scheduled task to be executed based on the success rate of the thread and the importance of the first scheduled task to be executed in the target scheduled task set is beneficial to ensuring that the important first scheduled task to be processed can be successfully processed, thereby improving the user experience.
[0094] In an implementation of the present application, the task configuration table includes R second scheduled tasks to be executed and P task types, each of the task types corresponds to at least one second scheduled task to be executed, the R and the P are both positive integers, and the R is greater than or equal to the P;
[0095] The determining N scheduled task sets based on the task configuration table includes:
[0096] Based on the P task types and the R second scheduled tasks to be executed, determine the P scheduled task sets to be processed, the P task types and the P scheduled task sets to be processed have a one-to-one correspondence, the task types of the second scheduled tasks to be executed in each of the scheduled task sets to be processed are the same, and each of the scheduled task sets to be processed includes at least one of the second scheduled tasks to be executed;
[0097] Based on the task configuration table and the P scheduled task sets to be processed, the N scheduled task sets are determined.
[0098] Among them, task types include but are not limited to the following: payment tasks, loan tasks, and financial management tasks, etc.
[0099] The second scheduled tasks to be executed are all scheduled tasks that need to be processed the next day.
[0100] The P sets of scheduled tasks to be processed include R second scheduled tasks to be executed.
[0101] The task type of each second scheduled task to be executed may be different, or the task type of at least one second scheduled task to be executed may be the same.
[0102] For example, if the task type is a payment task, the second scheduled task to be executed may be WeChat payment, bank card payment, balance payment in Alipay, Yu'ebao payment in Alipay, and so on.
[0103] For example, if the task configuration table includes 5 second pending scheduled tasks (A, B, C, D and E), where A belongs to task type 1, B belongs to task type 1, C belongs to task type 2, D belongs to task type 3 and E belongs to task type 2, then 3 pending scheduled task sets (J1, J2 and J3) can be determined, where J1 includes A and B, J2 includes C and E, and J3 includes D.
[0104] It can be seen that in the embodiment of the present application, the second scheduled tasks to be executed are divided based on the task types of the second scheduled tasks to be executed, which is beneficial to the subsequent processing of the second scheduled tasks to be executed based on the task types.
[0105] In an implementation of the present application, the task configuration table further includes S second task execution times, the second task execution time being the execution time of the second scheduled task to be executed in the scheduled task set to be processed, each second scheduled task to be executed in each scheduled task set to be processed corresponds to at least one second task execution time, and S is a positive integer, and S is greater than or equal to R;
[0106] The determining the N scheduled task sets based on the task configuration table and the P scheduled task sets to be processed includes:
[0107] Based on the S second task execution moments, the P to-be-processed scheduled task sets, the second preset duration, and the third preset duration, N second time periods are determined, each of the second time periods corresponding to at least one second task execution moment, the time difference of the second task execution moments within each second time period is greater than or less than the second preset duration, and the time difference of the second task execution moments within each second time period is less than the third preset duration, the second to-be-executed scheduled tasks corresponding to the second task execution moments within each second time period belong to the same to-be-processed scheduled task set, and N is greater than or equal to P;
[0108] The N scheduled task sets are determined based on the N second time periods, the N second time periods correspond to the N scheduled task sets one-to-one, and the second task execution times of the second scheduled tasks to be executed included in each of the scheduled task sets belong to the same time period.
[0109] The second preset duration may be 3 minutes, 10 minutes, or other durations.
[0110] The second preset time length is smaller than the third preset time length, and the third preset time length may be 4 minutes, 6 minutes, 15 minutes, and so on.
[0111] Among them, a set of scheduled tasks to be processed corresponds to at least one second time period.
[0112] Different second scheduled tasks to be executed may correspond to different second task execution times, or multiple second scheduled tasks to be executed may correspond to one second task execution time.
[0113] The second task execution time is the time for executing the second scheduled task to be executed.
[0114] For example, the set of scheduled tasks to be processed is #1, where #1 includes task A1, task A2 and task A3. The second task execution time of task A1 is 08:20:30, 08:30:40 and 10:45:20, the execution time of task A2 includes 10:20:30, 11:30:40 and 11:45:20, and the execution time of task A3 includes 08:22:50, 09:48:40 and 10:45:20. Assuming that the second preset time is 2 minutes and the third preset time is 20 minutes, it can be determined that the times with a time difference greater than or equal to 2 minutes and less than 20 minutes are A1: 08:20:30, 08:30:40, A3: 08:22:50, and the corresponding scheduled task set 1 includes (task A1 and task A3); A1: 10:45:20, A3: 10:45:20, and the scheduled task set 2 includes (task A1, task A3, task C); A2: 11:30:40, 11:45:20, so the scheduled task set 3 includes task A2; A3: 09:45:40, so the scheduled task set 4 includes task A3.
[0115] It can be seen that in the embodiment of the present application, acquiring scheduled tasks within a certain period of time at one time is conducive to reducing the complexity of acquiring scheduled tasks.
[0116] In an implementation of the present application, the preset thread configuration table includes at least one thread, and the thread is bound to a task type;
[0117] The determining of a target thread for processing the target scheduled task set includes:
[0118] Based on the task type corresponding to the scheduled task set, the target thread is determined in the at least one thread.
[0119] There may be a binding relationship between multiple threads and the same task type, or there may be a one-to-one correspondence between threads and task types.
[0120] If the second scheduled task to be executed corresponds to a plurality of second task execution times, the thread corresponding to the second scheduled task to be executed processes the second scheduled task to be executed at the plurality of second task execution times.
[0121] For example, if the target scheduled task set includes (task A, task B and task C), the task type of task A is type 1, the type of task B is type 2, and the type of task C is type C. Assuming that type 1 is bound to thread 1, type 2 is bound to thread 2, and type 3 is bound to thread 3, thread 1 is used to process task A, thread 2 is used to process task B, and thread 3 is used to process task C.
[0122] It can be seen that in the embodiment of the present application, different threads process different scheduled tasks, which is conducive to improving the success rate of scheduled task processing.
[0123] In an implementation of the present application, the step of establishing a trigger schedule based on the N scheduled task sets includes:
[0124] Determine the start time of the time period corresponding to each of the scheduled task sets;
[0125] Determine each triggering moment based on each starting moment and a fourth preset duration to obtain N triggering moments;
[0126] The trigger time table is established based on the N trigger time.
[0127] Among them, each triggering moment is earlier than each starting moment.
[0128] Among them, the fourth preset duration can be 20 seconds, 34 seconds, or other durations, and so on.
[0129] The time length that the trigger moment is earlier than the corresponding initial moment is the fourth preset time length.
[0130] The trigger time table includes N trigger times, and the N trigger times are different.
[0131] It can be seen that in the embodiment of the present application, the trigger time is determined based on the short start time and the preset duration corresponding to the scheduled task set, which is conducive to avoiding the device from monitoring the execution time of the scheduled task set and reducing the complexity of the terminal device.
[0132] In a possible implementation, after the target thread is used to process the target scheduled task set, the method further includes:
[0133] The target thread and the processing result are associated and stored in the third database.
[0134] It can be seen that in the embodiment of the present application, it is beneficial to extract the processing results based on threads.
[0135] With the above Figure 2 For details on the embodiments shown in the drawings, please refer to Figure 3 , Figure 3 1 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present application. As shown in the figure, the electronic device includes a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the program includes instructions for executing the following steps:
[0136] Triggering a first acquisition instruction, where the first acquisition instruction is used to instruct to acquire a task configuration table from a first database;
[0137] Determine N scheduled task sets based on the task configuration table, where N is a positive integer;
[0138] Establishing a trigger schedule based on the N scheduled task sets, and storing the N scheduled task sets in a second database, wherein the trigger schedule includes N trigger moments, and the N scheduled task sets correspond one-to-one to the N trigger moments;
[0139] Determine the earliest trigger time in the trigger time table as the first trigger time, and trigger a second acquisition instruction at the first trigger time, the second acquisition instruction is used to instruct to acquire the target scheduled task set corresponding to the first trigger time, and the trigger times in the trigger time table are all later than the trigger time of the first acquisition instruction;
[0140] Based on the target scheduled task set and a preset thread configuration table, determining a target thread for processing the target scheduled task set;
[0141] The target thread is used to process the target scheduled task set; the first trigger time is deleted from the trigger time table until all the trigger times in the trigger time table are defined as the first trigger time.
[0142] In an implementation of the present application, the task configuration table includes S first scheduled tasks to be executed and T first task execution times, and each of the first scheduled tasks to be executed corresponds to at least one first task execution time;
[0143] In terms of determining N scheduled task sets based on the task configuration table, the program includes instructions for further performing the following steps:
[0144] Determining the earliest first task execution time and the latest first task execution time among the T first task execution times;
[0145] Based on the earliest first task execution time, the latest first task execution time and the first preset duration, determine N first time periods, the duration of each of the first time periods is less than or equal to the first preset duration;
[0146] Based on the N first time periods, the S first scheduled tasks to be executed and the T first task execution times, the N scheduled task sets are determined, the N first time periods and the N scheduled task sets correspond one to one, and the first task execution time of the first scheduled task to be executed included in each scheduled task set is within the same time period.
[0147] In an implementation of the present application, the preset thread configuration table includes at least one thread and a success rate of each thread executing a task, the task configuration table also includes the importance of each first scheduled task to be executed, the target scheduled task set includes at least one first scheduled task to be executed, and the number of first scheduled tasks to be executed included in the target scheduled task set is less than or equal to S;
[0148] In terms of determining a target thread for processing the target scheduled task set based on the target scheduled task set and a preset thread configuration table, the program includes instructions for executing the following steps:
[0149] Sorting the at least one thread according to a descending order of success rate to obtain a thread subset;
[0150] Sorting the at least one first scheduled task to be executed included in the target scheduled task set based on a descending order of importance to obtain a first subset of scheduled tasks to be executed;
[0151] Based on a first allocation principle, the first to-be-executed scheduled task in the first to-be-executed scheduled task subset is allocated to a thread in the thread subset for processing, and the thread processing the first to-be-executed scheduled task is determined to be the target thread. The first allocation principle is that the position of the thread processing the first to-be-executed scheduled task in the thread subset is the same as the position of the first to-be-executed scheduled task in the first to-be-executed scheduled task subset.
[0152] In an implementation of the present application, the task configuration table includes R second scheduled tasks to be executed and P task types, each of the task types corresponds to at least one second scheduled task to be executed, the R and the P are both positive integers, and the R is greater than or equal to the P;
[0153] In terms of determining N scheduled task sets based on the task configuration table, the above program includes instructions for executing the following steps:
[0154] Based on the P task types and the R second scheduled tasks to be executed, determine the P scheduled task sets to be processed, the P task types and the P scheduled task sets to be processed have a one-to-one correspondence, the task types of the second scheduled tasks to be executed in each of the scheduled task sets to be processed are the same, and each of the scheduled task sets to be processed includes at least one of the second scheduled tasks to be executed;
[0155] Based on the task configuration table and the P scheduled task sets to be processed, the N scheduled task sets are determined.
[0156] In an implementation of the present application, the task configuration table further includes S second task execution times, the second task execution time being the execution time of the second scheduled task to be executed in the scheduled task set to be processed, each second scheduled task to be executed in each scheduled task set to be processed corresponds to at least one second task execution time, and S is a positive integer, and S is greater than or equal to R;
[0157] In terms of determining the N scheduled task sets based on the task configuration table and the P scheduled task sets to be processed, the above program includes instructions for executing the following steps:
[0158] Based on the S second task execution moments, the P to-be-processed scheduled task sets, the second preset duration, and the third preset duration, determine N second time periods, each of the second time periods includes at least one second task execution moment, the time difference of the second task execution moments within each second time period is greater than or equal to the second preset duration, and the time difference of the second task execution moments within each second time period is less than the third preset duration, the second to-be-processed scheduled tasks corresponding to the second task execution moments within each second time period belong to the same to-be-processed scheduled task set, and N is greater than or equal to P;
[0159] The N scheduled task sets are determined based on the N second time periods, the N second time periods correspond to the N scheduled task sets one-to-one, and the second task execution times of the second scheduled tasks to be executed included in each of the scheduled task sets belong to the same time period.
[0160] In an implementation of the present application, the preset thread configuration table includes at least one thread, and there is a binding relationship between the thread and the task type;
[0161] In terms of determining the target thread for processing the target scheduled task set, the program includes instructions for executing the following steps:
[0162] Based on the task type corresponding to the scheduled task set, the target thread is determined in the at least one thread.
[0163] In one implementation of the present application, in terms of establishing a trigger schedule based on the N scheduled task sets, the above program includes instructions for executing the following steps:
[0164] Determine the start time of the time period corresponding to each of the scheduled task sets;
[0165] Determine each triggering moment based on each starting moment and a fourth preset duration to obtain N triggering moments;
[0166] The trigger time table is established based on the N trigger time.
[0167] It should be noted that the specific implementation process of this embodiment can refer to the specific implementation process described in the above method embodiment, which will not be described here.
[0168] See also Figure 4 , Figure 4 A timed task processing device provided in an embodiment of the present application is applied to an electronic device, and the device includes:
[0169] A first triggering unit 401 is used to trigger a first acquisition instruction, where the first acquisition instruction is used to instruct to acquire a task configuration table from a first database;
[0170] A first determining unit 402 is configured to determine N scheduled task sets based on the task configuration table, where N is a positive integer;
[0171] An establishing unit 403 is used to establish a trigger schedule based on the N scheduled task sets, and store the N scheduled task sets in a second database, wherein the trigger schedule includes N trigger moments, and the N scheduled task sets correspond to the N trigger moments one by one;
[0172] A second triggering unit 404 is used to determine the earliest triggering time in the triggering timetable as the first triggering time, and to trigger a second acquisition instruction at the first triggering time, wherein the second acquisition instruction is used to instruct to acquire a target scheduled task set corresponding to the first triggering time, and the triggering times in the triggering timetable are all later than the triggering time of the first acquisition instruction;
[0173] A second determining unit 405 is used to determine a target thread for processing the target scheduled task set based on the target scheduled task set and a preset thread configuration table;
[0174] The processing unit 406 is used to process the target scheduled task set using the target thread; delete the first trigger time in the trigger time table until all the trigger times in the trigger time table are defined as the first trigger time.
[0175] In an implementation of the present application, the task configuration table includes S first scheduled tasks to be executed and T first task execution times, and each of the first scheduled tasks to be executed corresponds to at least one first task execution time;
[0176] In determining the N scheduled task sets based on the task configuration table, the first determining unit 402 includes instructions for further performing the following steps:
[0177] Determining the earliest first task execution time and the latest first task execution time among the T first task execution times;
[0178] Based on the earliest first task execution time, the latest first task execution time and the first preset duration, N first time periods are determined, and the duration of each first time period is less than or equal to the first preset duration; based on the N first time periods, the S first scheduled tasks to be executed and the T first task execution times, the N scheduled task sets are determined, the N first time periods and the N scheduled task sets correspond one-to-one, and the first task execution time of the first scheduled task to be executed included in each scheduled task set is within the same time period.
[0179] In an implementation of the present application, the preset thread configuration table includes at least one thread and a success rate of each thread executing a task, the task configuration table also includes the importance of each first scheduled task to be executed, the target scheduled task set includes at least one first scheduled task to be executed, and the number of first scheduled tasks to be executed included in the target scheduled task set is less than or equal to S;
[0180] In determining the target thread for processing the target scheduled task set, the second determining unit 404 includes instructions for executing the following steps:
[0181] Sorting the at least one thread according to a descending order of success rate to obtain a thread subset;
[0182] Sorting the at least one first scheduled task to be executed included in the target scheduled task set based on a descending order of importance to obtain a first subset of scheduled tasks to be executed;
[0183] Based on a first allocation principle, the first to-be-executed scheduled task in the first to-be-executed scheduled task subset is processed correspondingly to a thread in the thread subset, and the thread processing the first to-be-executed scheduled task is determined as the target thread. The first allocation principle is that the position of the thread processing the first to-be-executed scheduled task in the thread subset is the same as the position of the first to-be-executed scheduled task in the first to-be-executed scheduled task subset.
[0184] In an implementation of the present application, the task configuration table includes R second scheduled tasks to be executed and P task types, each of the task types corresponds to at least one second scheduled task to be executed, the R and the P are both positive integers, and the R is greater than or equal to the P;
[0185] In determining the N scheduled task sets based on the task configuration table, the first determining unit 402 includes instructions for executing the following steps:
[0186] Based on the P task types and the R second scheduled tasks to be executed, determine the P scheduled task sets to be processed, the P task types and the P scheduled task sets to be processed have a one-to-one correspondence, the task types of the second scheduled tasks to be executed in each of the scheduled task sets to be processed are the same, and each of the scheduled task sets to be processed includes at least one of the second scheduled tasks to be executed;
[0187] Based on the task configuration table and the P scheduled task sets to be processed, the N scheduled task sets are determined.
[0188] In an implementation of the present application, the task configuration table further includes S second task execution times, the second task execution time being the execution time of the second scheduled task to be executed in the scheduled task set to be processed, each second scheduled task to be executed in each scheduled task set to be processed corresponds to at least one second task execution time, and S is a positive integer, and S is greater than or equal to R;
[0189] In terms of determining the N scheduled task sets based on the task configuration table and the P scheduled task sets to be processed, the first determining unit 402 includes instructions for executing the following steps:
[0190] Based on the S second task execution moments, the P to-be-processed scheduled task sets, the second preset duration, and the third preset duration, determine N second time periods, each of the second time periods includes at least one second task execution moment, the time difference of the second task execution moments within each second time period is greater than or equal to the second preset duration, and the time difference of the second task execution moments within each second time period is less than the third preset duration, the second to-be-processed scheduled tasks corresponding to the second task execution moments within each second time period belong to the same to-be-processed scheduled task set, and N is greater than or equal to P;
[0191] The N scheduled task sets are determined based on the N second time periods, the N second time periods correspond to the N scheduled task sets one-to-one, and the second task execution times of the second scheduled tasks to be executed included in each of the scheduled task sets belong to the same time period.
[0192] In an implementation of the present application, the preset thread configuration table includes at least one thread, and there is a binding relationship between the thread and the task type;
[0193] In determining the target thread for processing the target scheduled task set, the second determining unit 405 includes instructions for executing the following steps:
[0194] Based on the task type corresponding to the scheduled task set, the target thread is determined in the at least one thread.
[0195] In an implementation of the present application, in terms of establishing a trigger schedule based on the N scheduled task sets, the establishing unit 403 includes instructions for executing the following steps:
[0196] Determine the start time of the time period corresponding to each of the scheduled task sets;
[0197] Determine each triggering moment based on each starting moment and a fourth preset duration to obtain N triggering moments;
[0198] The trigger time table is established based on the N trigger time.
[0199] It should be noted that the first triggering unit 401 , the first determining unit 402 , the establishing unit 403 , the second triggering unit 404 , the second determining unit 40 and the processing unit 406 may be implemented by a processor.
[0200] An embodiment of the present application also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program for timed task processing, wherein the computer program enables a computer to execute some or all of the steps described for the electronic device in the above method embodiment.
[0201] The present application also provides a computer program product, wherein the computer program product includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute some or all of the steps described for the electronic device in the above method. The computer program product may be a software installation package.
[0202] The steps of the method or algorithm described in the embodiment of the present application can be implemented in a hardware manner, or can be implemented by a processor executing software instructions. The software instructions can be composed of corresponding software modules, and the software modules can be stored in a random access memory (Random Access Memory, RAM), a flash memory, a read-only memory (Read Only Memory, ROM), an erasable programmable read-only memory (Erasable Programmable ROM, EPROM), an electrically erasable programmable read-only memory (Electrically EPROM, EEPROM), a register, a hard disk, a mobile hard disk, a read-only compact disk (CD-ROM) or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an ASIC. In addition, the ASIC can be located in an access network device, a target network device, or a core network device. Of course, the processor and the storage medium can also be present in an access network device, a target network device, or a core network device as discrete components.
[0203] Those skilled in the art should be aware that in one or more of the above examples, the functions described in the embodiments of the present application can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiments of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (Digital Subscriber Line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrations. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a digital video disc (DVD)), or a semiconductor medium (eg, a solid state disk (SSD)).
[0204] The specific implementation methods described above further illustrate the purpose, technical solutions and beneficial effects of the embodiments of the present application. It should be understood that the above description is only the specific implementation method of the embodiments of the present application and is not intended to limit the protection scope of the embodiments of the present application. Any modifications, equivalent substitutions, improvements, etc. made on the basis of the technical solutions of the embodiments of the present application should be included in the protection scope of the embodiments of the present application.
Claims
1. A method for processing a scheduled task, characterized in that: Applied to electronic equipment, the method comprises: Triggering a first acquisition instruction, where the first acquisition instruction is used to instruct to acquire a task configuration table from a first database; Determine N scheduled task sets based on the task configuration table, where N is a positive integer; Establishing a trigger schedule based on the N scheduled task sets, and storing the N scheduled task sets in a second database, wherein the trigger schedule includes N trigger moments, and the N scheduled task sets correspond one-to-one to the N trigger moments; Determine the earliest trigger time in the trigger time table as the first trigger time, and trigger a second acquisition instruction at the first trigger time, the second acquisition instruction is used to instruct to acquire the target scheduled task set corresponding to the first trigger time, and the trigger times in the trigger time table are all later than the trigger time of the first acquisition instruction; Based on the target scheduled task set and a preset thread configuration table, determining a target thread for processing the target scheduled task set; The target thread is used to process the target scheduled task set; the first trigger time is deleted from the trigger time table until all the trigger times in the trigger time table are defined as the first trigger time.
2. The method according to claim 1, characterized in that The task configuration table includes S first scheduled tasks to be executed and T first task execution times, each of the first scheduled tasks to be executed corresponds to at least one first task execution time, and S and N are positive integers; The determining N scheduled task sets based on the task configuration table includes: Determining the earliest first task execution time and the latest first task execution time among the T first task execution times; Based on the earliest first task execution time, the latest first task execution time and a first preset duration, determining N first time periods, where the duration of the first time period is less than or equal to the first preset duration; Based on the N first time periods, the S first scheduled tasks to be executed and the T first task execution times, the N scheduled task sets are determined, the N first time periods and the N scheduled task sets correspond one to one, and the first task execution time of the first scheduled task to be executed included in each scheduled task set is within the same time period.
3. The method according to claim 2, characterized in that The preset thread configuration table includes at least one thread and a success rate of each thread in executing a task, the task configuration table also includes the importance of each first scheduled task to be executed, the target scheduled task set includes at least one first scheduled task to be executed, and the number of first scheduled tasks to be executed included in the target scheduled task set is less than or equal to S; The step of determining a target thread for processing the target scheduled task set based on the target scheduled task set and a preset thread configuration table includes: Sorting the at least one thread according to a descending order of success rate to obtain a thread subset; Sorting the at least one first scheduled task to be executed included in the target scheduled task set based on a descending order of importance to obtain a first subset of scheduled tasks to be executed; Based on a first allocation principle, the first to-be-executed scheduled task in the first to-be-executed scheduled task subset is allocated to a thread in the thread subset for processing, and the thread processing the first to-be-executed scheduled task is determined to be the target thread. The first allocation principle is that the position of the thread processing the first to-be-executed scheduled task in the thread subset is the same as the position of the first to-be-executed scheduled task in the first to-be-executed scheduled task subset.
4. The method according to claim 1, characterized in that: The task configuration table includes R second scheduled tasks to be executed and P task types, each of the task types corresponds to at least one second scheduled task to be executed, R and P are both positive integers, and R is greater than or equal to P; The determining N scheduled task sets based on the task configuration table includes: Based on the P task types and the R second scheduled tasks to be executed, determine the P scheduled task sets to be processed, the P task types and the P scheduled task sets to be processed have a one-to-one correspondence, the task types of the second scheduled tasks to be executed in each of the scheduled task sets to be processed are the same, and each of the scheduled task sets to be processed includes at least one of the second scheduled tasks to be executed; Based on the task configuration table and the P scheduled task sets to be processed, the N scheduled task sets are determined.
5. The method according to claim 4, characterized in that The task configuration table further includes S second task execution times, where the second task execution time is the execution time of the second scheduled task to be executed in the scheduled task set to be processed, and each second scheduled task to be executed in each scheduled task set to be processed corresponds to at least one second task execution time, and S is a positive integer, and S is greater than or equal to R; The determining the N scheduled task sets based on the task configuration table and the P scheduled task sets to be processed includes: Based on the S second task execution moments, the P to-be-processed scheduled task sets, the second preset duration, and the third preset duration, determine N second time periods, each of the second time periods includes at least one second task execution moment, the time difference of the second task execution moments within each second time period is greater than or equal to the second preset duration, and the time difference of the second task execution moments within each second time period is less than the third preset duration, the second to-be-processed scheduled tasks corresponding to the second task execution moments within each second time period belong to the same to-be-processed scheduled task set, and N is greater than or equal to P; The N scheduled task sets are determined based on the N second time periods, the N second time periods correspond to the N scheduled task sets one-to-one, and the second task execution times of the second scheduled tasks to be executed included in each of the scheduled task sets belong to the same time period.
6. The method according to claim 5, characterized in that The preset thread configuration table includes at least one thread, and there is a binding relationship between the thread and the task type; The step of determining a target thread for processing the target scheduled task set based on the target scheduled task set and a preset thread configuration table includes: Based on the task type corresponding to the scheduled task set, the target thread is determined in the at least one thread.
7. The method according to claim 2 or 5, characterized in that: The establishing of a trigger schedule based on the N scheduled task sets includes: Determine the start time of the time period corresponding to each of the scheduled task sets; Determine each triggering moment based on each starting moment and a fourth preset duration to obtain N triggering moments; The trigger time table is established based on the N trigger time.
8. A timed task processing device, characterized in that: Applied to electronic equipment, the device comprises: A first triggering unit, used to trigger a first acquisition instruction, where the first acquisition instruction is used to instruct to acquire a task configuration table from a first database; A first determining unit, configured to determine N scheduled task sets based on the task configuration table, where N is a positive integer; An establishing unit, configured to establish a trigger schedule based on the N scheduled task sets, and store the N scheduled task sets in a second database, wherein the trigger schedule includes N trigger moments, and the N scheduled task sets correspond one-to-one to the N trigger moments; A second trigger unit is used to determine the earliest trigger time in the trigger time table as the first trigger time, and trigger a second acquisition instruction at the first trigger time, wherein the second acquisition instruction is used to instruct to acquire a target scheduled task set corresponding to the first trigger time, and the trigger times in the trigger time table are all later than the trigger time of the first acquisition instruction; A second determining unit, configured to determine a target thread for processing the target scheduled task set based on the target scheduled task set and a preset thread configuration table; A processing unit is used to process the target scheduled task set using the target thread; and to delete the first trigger time in the trigger time table until all the trigger times in the trigger time table are defined as the first trigger time.
9. An electronic device, characterized in that: The electronic device includes a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the programs include instructions for executing the steps in the method as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program is processed to execute the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Multi-task processing method and device based on service system, equipment and storage medium
CN110413388A
Task execution method and device, electronic equipment and storage medium
CN111767125A