Task scheduling method and device, computer equipment and storage medium

By integrating synchronous tasks and asynchronous tasks into the same working class and sharing data resources, the problem of incoherence of business processing in the existing asynchronous processing methods is solved, and task execution is simplified and resource saving is achieved.

CN119396541APending Publication Date: 2025-02-07CHINA MOBILE COMM GRP TERMINAL +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410526429.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-04-29
Publication Date
2025-02-07

AI Technical Summary

Technical Problem

In the existing asynchronous processing methods, synchronous operations are separated from asynchronous operations, resulting in incoherence of business processing, requiring additional internal logic transfer and context transfer, resulting in waste of resources and logical confusion.

Method used

Through the task scheduling method, synchronous tasks and asynchronous tasks are integrated into the same working class, allowing them to share data resources, reduce parameter passing, and simplify task execution process. The specific implementation includes executing pre-tasks through the working processor and determining subsequent tasks based on the task scheduling template. If the subsequent tasks are asynchronous tasks, they are executed by the asynchronous processor.

Benefits of technology

It realizes seamless integration between synchronous tasks and asynchronous tasks, shares data resources, reduces parameter transfer between task processes, simplifies task execution process, and saves system resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119396541A_ABST
    Figure CN119396541A_ABST
Patent Text Reader

Abstract

The invention relates to a task scheduling method and device, computer equipment and a storage medium, and relates to the technical field of data processing. The method comprises the following steps: executing a preposed task through a working processor to obtain a return value of the preposed task; determining subsequent tasks of the front tasks according to a task scheduling template sequence; the task scheduling template is used for defining an execution process of a business processing work class and a relationship between a return value of a front task and a task type of a subsequent task; under the condition that the subsequent task determined based on the return value of the front task is the asynchronous task, executing the subsequent task through the asynchronous processor; through the method, the synchronous task and the asynchronous task can be integrated into the same work class, so that the synchronous task and the asynchronous task share data resources, parameter transmission among different task processes is reduced, the task execution process is simplified, and system resources are saved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of data processing technology, and in particular to a task scheduling method, apparatus, computer equipment and storage medium. Background Art

[0002] Asynchronous processing plays a vital role in modern computer systems and applications. Asynchronous processing means that when a program executes an operation, it can continue to perform other work without waiting for the completion of the operation, thereby improving response speed, improving resource utilization and other effects.

[0003] In related technologies, asynchronous processing is usually performed through an independent thread, that is, a new thread is opened to process a specified method or class. If a callback is required, the callback method needs to be passed to the specified method or specified class as a parameter for processing.

[0004] However, in the above asynchronous processing method, synchronous operations are separated from asynchronous operations, which makes business processing incoherent and requires additional internal logic transfer and context transfer. If the internal logic needs to call an external asynchronous interface, it needs to be processed by itself, such as loop waiting, which may cause resource waste and logical confusion. Summary of the invention

[0005] The embodiments of the present application provide a task scheduling method, apparatus, computer equipment and storage medium, which can integrate synchronous tasks and asynchronous tasks into the same work class, so that synchronous tasks and asynchronous tasks share data resources, reduce parameter transfer between different task processes, thereby simplifying the task execution process and saving system resources. The technical solution is as follows.

[0006] In one aspect, a task scheduling method is provided, the method comprising:

[0007] Executing the predecessor task through the work processor to obtain a return value of the predecessor task;

[0008] Determine the subsequent tasks of the preceding task in accordance with the order of the task scheduling template; the task scheduling template is used to define the execution flow of the business processing work class and the relationship between the return value of the preceding task and the task type of the subsequent task;

[0009] In a case where the subsequent task determined based on the return value of the predecessor task is an asynchronous task, the subsequent task is executed by an asynchronous processor.

[0010] On the other hand, a task scheduling device is provided, the device comprising:

[0011] A first task execution module, used for executing a predecessor task through a work processor to obtain a return value of the predecessor task;

[0012] A task determination module, used to determine the subsequent tasks of the predecessor task in accordance with the order of the task scheduling template; the task scheduling template is used to define the execution process of the business processing work class and the relationship between the return value of the predecessor task and the task type of the subsequent task;

[0013] The second task execution module is used to execute the subsequent task through an asynchronous processor when it is determined that the subsequent task is an asynchronous task based on the return value of the predecessor task.

[0014] In a possible implementation, the second task execution module is used to:

[0015] In the case where the call type corresponding to the subsequent task is a work set call, obtaining a work set associated with the subsequent task; the work set includes at least two mutually related work tasks;

[0016] The work tasks in the work set are executed by the asynchronous processor according to the scheduling logic indicated by the work set.

[0017] In a possible implementation, the work set includes mutually nested work tasks and sub-work sets; wherein, the mutual nesting means that a work task has a corresponding sub-work set, and the sub-work set includes at least two mutually related work tasks.

[0018] In a possible implementation, the work set includes the execution order of each interrelated work task and / or dependency conditions.

[0019] In a possible implementation, the second task execution module is configured to execute a work task corresponding to the subsequent task when the call type corresponding to the subsequent task is a work call.

[0020] In a possible implementation, the task scheduling template is further used to define the relationship between the task execution progress and the task execution order; the device further includes:

[0021] A progress monitoring module, used for monitoring the task execution progress in the work processor in real time;

[0022] The task determination module is used to determine the subsequent task according to the relationship between the task execution progress and the task execution order indicated by the task scheduling template.

[0023] On the other hand, a computer device is provided, the computer device comprising a processor and a memory, the memory storing at least one computer program, the at least one computer program being loaded and executed by the processor to implement the above-mentioned task scheduling method.

[0024] On the other hand, a computer-readable storage medium is provided, wherein at least one computer program is stored in the computer-readable storage medium, and the computer program is loaded and executed by a processor to implement the above-mentioned task scheduling method.

[0025] On the other hand, a computer program product is provided, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions, which, when executed by a computer, cause the computer to execute to implement the task scheduling method provided in the above-mentioned various optional implementations.

[0026] The technical solution provided by this application may have the following beneficial effects:

[0027] The task scheduling method provided in the embodiment of the present application defines the execution process of the business processing work class and the relationship between the task return value of the predecessor task and the task type of the subsequent task through a task scheduling template, so that when the execution process of the business processing work class is performed, the predecessor task is executed according to the execution process through the work processor according to the task scheduling template, the return value of the predecessor task is obtained, and the task type of the subsequent task is determined based on the return value of the predecessor task, and when the subsequent task is an asynchronous task, the subsequent task is executed through the asynchronous processor; through the above method, synchronous tasks and asynchronous tasks can be integrated into the same work class, so that synchronous tasks and asynchronous tasks share data resources, reducing parameter transfer between different task processes, thereby simplifying the task execution process and saving system resources.

[0028] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0030] Figure 1 A flowchart of a task scheduling method provided by an exemplary embodiment of the present application is shown;

[0031] Figure 2 An architecture diagram of a task scheduling device corresponding to a task scheduling method provided by an exemplary embodiment of the present application is shown;

[0032] Figure 3 A schematic diagram of the architecture involved in a working set provided by an exemplary embodiment of the present application is shown;

[0033] Figure 4 A flowchart of a task scheduling method provided by an exemplary embodiment of the present application is shown;

[0034] Figure 5 A schematic diagram showing a task scheduling process provided by an exemplary embodiment of the present application is shown;

[0035] Figure 6 A block diagram of a task scheduling device provided by an exemplary embodiment of the present application is shown;

[0036] Figure 7 is a structural block diagram of a computer device according to an exemplary embodiment;

[0037] Figure 8 It is a structural block diagram of a computer device according to an exemplary embodiment. DETAILED DESCRIPTION

[0038] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0039] First, the terms involved in this application are explained:

[0040] 1) Message Queues

[0041] Message queues are a mechanism for applications to communicate. Applications communicate by reading and writing messages without establishing a direct connection. Message queues provide a channel for message transmission, allowing applications to specify the priority associated with processing messages. Message queues have the following main advantages:

[0042] a. Decoupled applications - senders and receivers do not need to be online at the same time. This enables asynchronous message delivery, which can greatly improve the scalability of the system.

[0043] b. Peak shaving and valley filling - The message queue can accumulate more messages when the receiver is too slow to process the messages, and then send these messages when the receiver is ready. This module can prevent the receiver from being overloaded.

[0044] c. Reliability - Message queues provide persistent storage, so messages will not be lost even if the receiver is unavailable.

[0045] d. Order guarantee - Message queues usually provide FIFO (First-In-First-Out) transmission order guarantee.

[0046] e. Message filtering - The message queue can be filtered according to message attributes and only receive messages that meet the filtering rules.

[0047] Currently, message queue implementations include RabbitMQ, Kafka, RocketMQ, ActiveMQ, ZeroMQ, etc.

[0048] Message queues play an important role in microservice architecture and distributed applications, enabling application decoupling and asynchronous communication.

[0049] 2) Timing Scheduler

[0050] The timer scheduler is used to execute a specific method at a specified time, usually through a thread.

[0051] Commonly used timing scheduling frameworks include:

[0052] Quartz: A fully open source task scheduling framework that provides a simple yet powerful mechanism for scheduling jobs in Java applications.

[0053] Spring Scheduling: The task scheduling module that comes with the Spring framework uses the @Scheduled annotation to schedule tasks.

[0054] Cron4j: A timed task framework based on Cron expressions. It is a lightweight alternative to Quartz with simpler configuration, but its disadvantage is that it does not support clustering and persistence.

[0055] SchedulerX: A Distributed Quartz that solves the problem that Quartz cannot scale horizontally well. It implements Quartz clustering by deploying multiple SchedulerX servers.

[0056] Elastic-Job: Dangdang's open source distributed timed task framework uses Zookeeper to implement clustering and persistence, with a timing accuracy of milliseconds.

[0057] XXL-JOB: is a lightweight distributed task scheduling platform, whose core design goal is rapid development, simple learning, lightweight, and easy to expand. The source code has been developed and connected to the online product lines of many companies, and it can be used out of the box.

[0058] In the related technology, most frameworks or systems currently use independent threads for asynchronous processing; or, based on messages / events for processing, however, in the above asynchronous processing method, since synchronous operations and asynchronous operations are performed by different operators, that is, producers and consumers are separated, different operators correspond to different work classes, which makes business processing incoherent. Since usually one message processes one logic, it will lead to too many messages required for the interaction between the two, and too many consumers. If a business process contains multiple asynchronous or time-consuming operations, there will be message confusion; the present application provides a task scheduling method, which defines the return value of the work class and the task execution method through the task scheduling template, and uses this as a basis to dynamically determine the execution process and processing method of subsequent tasks, thereby integrating synchronous operations and asynchronous operations in the same work class. Through the above template and return value mechanism, synchronous and asynchronous tasks can be flexibly combined to form an orderly task pipeline, which can not only ensure the dependency between tasks, but also make full use of system resources for efficient concurrent execution.

[0059] Figure 1 A flowchart of a task scheduling method provided by an exemplary embodiment of the present application is shown. The method can be executed by a computer device, which can be a task scheduling device, which can be implemented as a terminal or a server. The task scheduling device can include a work processor and an asynchronous processor, wherein the work processor is used to process synchronous tasks in a work class, and the asynchronous processor is used to process asynchronous tasks in a work class. Figure 1 As shown, the method may include the following steps:

[0060] Step 110: Execute the predecessor task through the work processor to obtain the return value of the predecessor task.

[0061] In an embodiment of the present application, a computer device executes each task according to the execution process indicated by a task scheduling template; wherein, a predecessor task refers to a task that is executed first in the order of the task execution process; the return value of a task refers to meaningful data generated after the task is completed; due to the different tasks and implemented functions, the types of task return values ​​may include result data: such as filtered lists, calculated values, summary statistics, etc.; status indication: such as whether the task execution is successful, specific error codes, etc.; metadata or descriptive information: such as execution time, number of records of processed data, resource usage, etc., as well as other return results that match the task requirements, which are not restricted by the present application.

[0062] Step 120, determining the subsequent tasks of the predecessor task according to the task scheduling template sequence; the task scheduling template is used to define the execution flow of the business processing work class and the relationship between the return value of the predecessor task and the task type of the subsequent task.

[0063] In an embodiment of the present application, both synchronous tasks and asynchronous tasks are configured in the same business processing work class through a task scheduling template to ensure that the same context environment can be shared when the tasks are executed, such as the same business status, user session information, etc. In this way, when executing asynchronous tasks, there is no need for the business logic layer to pass parameters between different tasks. In the same business processing work class, synchronous tasks and asynchronous tasks can share parameters, and the task mobilization template automatically manages the passing of parameters, thereby simplifying the task execution process and saving system resources.

[0064] Based on different business requirements, the task scheduling template can indicate different combinations of synchronous tasks and asynchronous tasks, and the task combination and task execution process in the task scheduling template can be flexibly adjusted based on actual needs.

[0065] After the predecessor task is executed, the computer device determines the successor task of the predecessor task based on the execution process indicated by the task scheduling template, and judges the task type of the successor task based on the return value of the predecessor task, wherein the task type includes synchronous task and asynchronous task.

[0066] The relationship between the return value of the predecessor task and the task type of the subsequent task can be set based on actual task requirements, and this application does not impose any restrictions on this; illustratively, when the predecessor task is to query the target data in the database, and the subsequent task of the predecessor task is to obtain the target data, if the return result of the predecessor task is that the target data is queried, the subsequent task can be a synchronous task, that is, obtaining the target data from the database; if the return result of the predecessor task is that the target data is not queried, the subsequent task can be an asynchronous task, that is, obtaining the target data from other channels, or monitoring the database to obtain the target data when the target data is contained in the database.

[0067] In an embodiment of the present application, the computer device can determine whether the next task needs to be executed asynchronously based on the return value of each task, that is, determine whether the next task is an asynchronous task, wherein the business itself does not care how to achieve asynchrony, and the asynchronous execution logic makes its own judgment; when it is determined that asynchronous execution is required, asynchronous processing is performed, and when asynchronous execution is not required, the synchronous task is directly executed.

[0068] Step 130: When the subsequent task determined based on the return value of the predecessor task is an asynchronous task, the subsequent task is executed by an asynchronous processor.

[0069] To summarize, the task scheduling method provided in the embodiment of the present application defines the execution process of the business processing work class and the relationship between the task return value of the predecessor task and the task type of the subsequent task through a task scheduling template, so that when the execution process of the business processing work class is performed, the predecessor task is executed according to the execution process through the work processor according to the task scheduling template, and the return value of the predecessor task is obtained, and the task type of the subsequent task is determined based on the return value of the predecessor task, and when the subsequent task is an asynchronous task, the subsequent task is executed through the asynchronous processor; through the above method, synchronous tasks and asynchronous tasks can be integrated into the same work class, so that synchronous tasks and asynchronous tasks share data resources, reducing parameter transfer between different task processes, thereby simplifying the task execution process and saving system resources.

[0070] In the embodiment of the present application, the task operation can be defined as work. Figure 2 FIG. 1 shows an architecture diagram of a task scheduling device corresponding to a task scheduling method provided by an exemplary embodiment of the present application. Figure 2 As shown, the task scheduling device includes a work processor, a work executor, a work reporter, a work manager, a work unit interface, a work register, a work storage adapter, a work log adapter, a work asynchronous execution adapter, an asynchronous processor, and a work exception return code adapter;

[0071] Among them, the work processor, IWorkprocesser, is responsible for executing each method of work and returning the result;

[0072] The work executor, WorkExeHandler, executes work in a threaded manner and is implemented internally through IWorkprocesser.

[0073] The work reporter, IWorkResponser, is responsible for updating the work status, execution status, etc.

[0074] The work manager, IWorkManager, connects to the external API and calls IWokprocesser internally for processing.

[0075] Work unit interface, IWorkHandler, the business module defines specific work for the interface according to business requirements, and IWorkProcesser calls the specific implementation of the interface. The specific implementation refers to writing corresponding codes in the business module according to the specifications defined by the IWorkHandler interface to complete the method of interface declaration.

[0076] The work register, IWorkRegister, registers by scanning specific work for IWorkProcesser to call.

[0077] The work storage adapter, IWorkStoreAdapter, calls the specific implementation to access the work entity.

[0078] The work log adapter, IWorkStoreAdapter, calls the specific implementation to write the work log.

[0079] The work asynchronous execution adapter, IWorkExecuteAdapter, is responsible for calling the specific implementation to complete the asynchronous processing when the work needs to be processed asynchronously. The work asynchronous self-adapter can convert synchronous tasks into asynchronous forms and put them into the message queue, and the asynchronous executor takes the tasks from the message queue for asynchronous processing.

[0080] The work exception return code adapter, IWorkExceptionAdapter, is responsible for writing error information, converting exceptions, etc.

[0081] The communication and interaction modes of each device in the task scheduling device are as follows: Figure 2 As shown. Among them, the work storage adapter, asynchronous execution adapter, etc. are all extensible modules that can realize work persistence (such as persistence based on hibernate, persistence based on jpa mode, and can also implement interfaces to realize other persistence or cache-based operations), asynchronous implementation (such as persistence based on message queues, other methods can also be implemented by yourself), and environmental applicability (such as based on springMVC, springboot, etc., other methods can also implement adapter interfaces by yourself). The adapter mechanism is mainly to be compatible with different system frameworks, use different environmental dependencies, etc. Moreover, this solution is not an independent system, and there is no problem of separate operation and maintenance, which increases the difficulty of operation and maintenance deployment. Instead, it is directly loaded and used in the form of library files.

[0082] The task scheduling method provided in the embodiment of the present application customizes the task execution process through the task scheduling template, and can perform synchronous and asynchronous transformation according to actual needs, thereby reducing the problem of thread proliferation and improving development efficiency; further, the task scheduling method provided in the present application can also improve the reusability of the task scheduling process through the setting of the working set, Figure 3 FIG. 1 shows a schematic diagram of an architecture involved in a working set provided by an exemplary embodiment of the present application, such as Figure 3 As shown, the architecture includes components such as a work processor, a work set manager, a work set asynchronous execution adapter, and a work set execution processor;

[0083] Among them, the work processor, workHandler, that is, the specific work, creates a work set during the execution process.

[0084] The workset manager, workSetManager, is responsible for the creation of specific work and sub-worksets defined in the template process in the workset, that is, work creates worksets, worksets create sub-works, and sub-works can also create next-level worksets, so as to realize wireless extended process calls. Schematically, for the process of creating a desktop, it includes creating a virtual machine and assigning users; for the process of creating a virtual machine, it includes image copying and mounting a new disk; for the process of mounting a new disk, it includes creating a hard disk and mounting a disk. Among them, the workset corresponding to the work "create desktop process" includes two next-level tasks of "create virtual machine" and "assign user", the next-level workset corresponding to the work "create virtual machine" includes two next-level tasks of "image copying" and "mounting new disk", and the workset corresponding to the work "mounting new disk" includes two next-level tasks of "create hard disk" and "mounting hard disk"; among them, each process and each level of process can be reused separately to complete the corresponding work. Illustratively, if the "create virtual machine" process needs to be completed in the execution process of another task, the computer device can reuse the "create virtual machine" process included in the "create desktop process" task in another task, thereby improving execution efficiency and avoiding waste of resources caused by repeated process design.

[0085] The work set asynchronous execution adapter, IWorkSetExecuteAdapter, is used to asynchronously execute each process of the work set.

[0086] The work set execution processor, WorkSetExeHandler, is responsible for scheduling and executing each work in the work set.

[0087] The asynchronous execution of the work set and the work can be performed using a message queue.

[0088] Figure 4 A flowchart of a task scheduling method provided by an exemplary embodiment of the present application is shown. The method can be executed by a computer device, which can be a task scheduling device, which can be implemented as a terminal or a server. The task scheduling device can include a work processor and an asynchronous processor, wherein the work processor is used to process synchronous tasks in a work class, and the asynchronous processor is used to process asynchronous tasks in a work class. Figure 4 As shown, the method may include the following steps:

[0089] Step 410: Execute the predecessor task through the work processor to obtain the return value of the predecessor task.

[0090] After defining the execution flow of the business processing work class through the task scheduling template, the work processor can execute each task flow according to the task scheduling template, and determine whether the next task needs to be executed asynchronously based on the return value of each task. The business itself does not care about how to achieve asynchrony, and the asynchronous execution logic will make the judgment.

[0091] Among them, the task flow in the task scheduling template and the execution order of the task flow can be dynamically set based on actual needs.

[0092] Step 420, determining the subsequent tasks of the predecessor task according to the task scheduling template sequence; the task scheduling template is used to define the execution flow of the business processing work class and the relationship between the return value of the predecessor task and the task type of the subsequent task.

[0093] In a possible implementation, the task scheduling template is further used to define the relationship between the task execution progress and the task execution order; the method further includes:

[0094] Monitor the progress of task execution in the work processor in real time;

[0095] Determine the subsequent tasks according to the relationship between the task execution progress and the task execution sequence indicated by the task scheduling template.

[0096] Among them, the task execution progress can refer to the state or degree of completion from the start of the task flow to the completion process, usually expressed in the form of a percentage to reflect the current progress of the task. Schematically, if it is a periodic task, it can be calculated by dividing the number of completed stages by the total number of stages; if it is a workload-based task, it can be calculated based on the proportion of the completed workload to the total workload, etc. For example, if the predecessor task is input data, if the current task progress indicates that the remaining data does not exceed the data processing volume threshold, the subsequent task can be data preprocessing; if the current task progress indicates that the remaining data exceeds the data processing volume threshold, the data preprocessing step is skipped and the data processing step is performed directly, that is, the subsequent task is data processing. The relationship between the task execution progress and the task execution order defined by the task execution template can realize automatic adjustment of the execution process.

[0097] In one possible implementation, the task scheduling template may also define the relationship between the task execution progress and the task type of the subsequent task. Schematically, if the current task progress indicates that the remaining data is less than the data processing volume threshold, when the subsequent task is data preprocessing, the subsequent task may be a synchronous task; if the current task progress indicates that the remaining data is greater than the data processing volume threshold, when the subsequent task is data preprocessing, the subsequent task may be an asynchronous task.

[0098] It should be noted that the relationship between the task execution progress defined in the task scheduling template and the task type or task execution order of subsequent tasks is only illustrative. Based on different actual needs, different effects can be achieved by defining different relationships. The above two definition methods can be implemented separately or in combination, and this application does not impose any restrictions on this.

[0099] By associating the return value of the predecessor task or the task execution progress with the task type of the subsequent task, even if the task involves calling external interfaces to obtain data or perform certain operations, these external interfaces are asynchronous. You can also use the custom query task in the task scheduling template to conveniently query the external task results and make the next call. In other words, each task can call itself after a specified interval according to actual needs.

[0100] Step 430, when the subsequent task determined based on the return value of the predecessor task is an asynchronous task and the call type corresponding to the subsequent task is a work set call, obtain the work set associated with the subsequent task; the work set contains at least two mutually related work tasks.

[0101] Since the work task itself is implemented based on the task scheduling template, and the task scheduling template is extensible, a single work task itself can also be infinitely expanded; it should be noted that the extension of the task scheduling template can be configured in real time or at runtime. In this application, the task type of the subsequent task is dynamically determined by the return value of the predecessor task, thereby changing the original predefined process.

[0102] In a possible implementation, the work set includes mutually nested work tasks and sub-work sets; wherein, the mutual nesting means that the work task has a corresponding sub-work set, and the sub-work set includes at least two mutually related work tasks.

[0103] Step 440: Execute the work tasks in the work set by the asynchronous processor according to the scheduling logic indicated by the work set.

[0104] The asynchronous processor will track the workflow template corresponding to the work set, automatically call the work that needs to be executed, and ensure that it is executed in a predefined order.

[0105] In one possible case, the work set itself has no business logic and acts as a link between upper and lower level work; when the work set is applied, the work set calls the work task, and the work task calls itself. There is no strong dependency between the work and the next level of work (i.e., sub-work), so as to achieve the purpose of reusing the work itself.

[0106] In another possible case, the work set may also include the execution order of each interrelated work task and / or dependency conditions.

[0107] If you use the work task content to directly call other tasks, you cannot implement a complex process consisting of multiple complex work tasks. For example, a large work task itself contains different sub-tasks. The sub-tasks may have a sequence and dependency conditions, or the sub-tasks may be generated when they are needed at runtime, or the parameters in the sub-tasks need to be generated at runtime. In this case, the workflow template within the work set can define the above complex process, and data can be transferred between different tasks through the work set.

[0108] Step 450: When the subsequent task determined based on the return value of the predecessor task is an asynchronous task and the call type corresponding to the subsequent task is a work call, execute the work task corresponding to the subsequent task.

[0109] Figure 5 A schematic diagram of a task scheduling process provided by an exemplary embodiment of the present application is shown. Figure 5 As shown, the process includes:

[0110] S501, the work processor executes the preceding task.

[0111] S502, determine whether the preceding task is successfully executed, if so, execute S504, otherwise, execute S503.

[0112] S503, determine whether there is a failure method; the failure method refers to the coping method when the task execution fails; if so, execute the failure method, otherwise, end the task process.

[0113] S504, determine whether there is a subsequent task, if yes, execute S505, otherwise, end the task flow. Determine whether there is a subsequent task by tracking the task scheduling template.

[0114] S505, determining whether the subsequent task needs to be executed asynchronously, if so, starting the asynchronous execution logic, otherwise executing the subsequent task synchronously.

[0115] In the asynchronous execution logic, the asynchronous processor performs asynchronous execution by means of a message queue, adds the corresponding asynchronous task to the message queue through the message processor, and asynchronously processes the asynchronous tasks in the message queue in sequence through the message receiver, wherein, when the asynchronous task is determined to be a work call, an asynchronous work call is performed, and after the asynchronous execution is completed, the next subsequent task is obtained, and the work processor is returned to process the next subsequent task; when the asynchronous task is determined to be a work set call, an asynchronous work set call is performed, and the process includes:

[0116] S506: Obtain the work tasks that need to be executed in the current work set.

[0117] S507, determine whether the work task has not been executed; if so, execute the related work asynchronously.

[0118] S508, determine whether all current work tasks are completed, if so, execute S509, otherwise, asynchronously execute the work set logic.

[0119] S509, determine whether the work set has ended, if so, end the call, otherwise, asynchronously execute the work set logic.

[0120] To summarize, the task scheduling method provided in the embodiment of the present application defines the execution process of the business processing work class and the relationship between the task return value of the predecessor task and the task type of the subsequent task through a task scheduling template, so that when the execution process of the business processing work class is performed, the predecessor task is executed according to the execution process through the work processor according to the task scheduling template, and the return value of the predecessor task is obtained, and the task type of the subsequent task is determined based on the return value of the predecessor task, and when the subsequent task is an asynchronous task, the subsequent task is executed through the asynchronous processor; through the above method, synchronous tasks and asynchronous tasks can be integrated into the same work class, so that synchronous tasks and asynchronous tasks share data resources, reducing parameter transfer between different task processes, thereby simplifying the task execution process and saving system resources.

[0121] In addition, the task scheduling template also realizes the scalability of the task process through the mutual nesting application of work sets and work tasks, thereby improving the application flexibility and scenario applicability of the task scheduling method provided in this application.

[0122] Figure 6 A block diagram of a task scheduling device provided by an exemplary embodiment of the present application is shown. The device can be used for Figure 1 or Figure 4 All or part of the steps of the embodiment shown, such as Figure 6 As shown, the device comprises:

[0123] A first task execution module 610, configured to execute a preceding task through a work processor and obtain a return value of the preceding task;

[0124] The task determination module 620 is used to determine the subsequent tasks of the predecessor task according to the task scheduling template sequence; the task scheduling template is used to define the execution process of the business processing work class and the relationship between the return value of the predecessor task and the task type of the subsequent task;

[0125] The second task execution module 630 is configured to execute the subsequent task through an asynchronous processor when it is determined that the subsequent task is an asynchronous task based on the return value of the predecessor task.

[0126] In a possible implementation, the second task execution module 630 is used to:

[0127] In the case where the call type corresponding to the subsequent task is a work set call, obtaining a work set associated with the subsequent task; the work set includes at least two mutually related work tasks;

[0128] The work tasks in the work set are executed by the asynchronous processor according to the scheduling logic indicated by the work set.

[0129] In a possible implementation, the work set includes mutually nested work tasks and sub-work sets; wherein, the mutual nesting means that a work task has a corresponding sub-work set, and the sub-work set includes at least two mutually related work tasks.

[0130] In a possible implementation, the work set includes the execution order of each interrelated work task and / or dependency conditions.

[0131] In a possible implementation, the second task execution module 630 is used to execute the work task corresponding to the subsequent task when the call type corresponding to the subsequent task is a work call.

[0132] In a possible implementation, the task scheduling template is further used to define the relationship between the task execution progress and the task execution order; the device further includes:

[0133] A progress monitoring module, used for monitoring the task execution progress in the work processor in real time;

[0134] The task determination module 620 is used to determine the subsequent task according to the relationship between the task execution progress and the task execution order indicated by the task scheduling template.

[0135] To summarize, the task scheduling device provided in the embodiment of the present application defines the execution process of the business processing work class and the relationship between the task return value of the predecessor task and the task type of the subsequent task through a task scheduling template, so that when the execution process of the business processing work class is performed, the predecessor task is executed according to the execution process through the work processor according to the task scheduling template, and the return value of the predecessor task is obtained. The task type of the subsequent task is determined based on the return value of the predecessor task, and when the subsequent task is an asynchronous task, the subsequent task is executed through the asynchronous processor; thereby, synchronous tasks and asynchronous tasks can be integrated into the same work class, so that synchronous tasks and asynchronous tasks share data resources, reducing parameter transfer between different task processes, thereby simplifying the task execution process and saving system resources.

[0136] Figure 7 The structural block diagram of a computer device 700 shown in an exemplary embodiment of the present application is shown. The computer device can be implemented as the task scheduling device in the above scheme of the present application. The computer device 700 includes a central processing unit (CPU) 701, a system memory 704 including a random access memory (RAM) 702 and a read-only memory (ROM) 703, and a system bus 705 connecting the system memory 704 and the central processing unit 701. The computer device 700 also includes a large-capacity storage device 706 for storing an operating system 709, an application program 710 and other program modules 711.

[0137] Without loss of generality, the computer-readable medium may include computer storage media and communication media. Computer storage media include volatile and non-volatile, removable and non-removable media implemented by any method or technology for storing information such as computer-readable instructions, data structures, program modules or other data. Computer storage media include RAM, ROM, Erasable Programmable Read Only Memory (EPROM), Electronically-Erasable Programmable Read-Only Memory (EEPROM) flash memory or other solid-state storage technology, CD-ROM, Digital Versatile Disc (DVD) or other optical storage, cassette, tape, disk storage or other magnetic storage devices. Of course, those skilled in the art will know that the computer storage medium is not limited to the above. The above-mentioned system memory 704 and mass storage device 706 can be collectively referred to as memory.

[0138] According to various embodiments of the present disclosure, the computer device 700 can also be connected to a remote computer on the network through a network such as the Internet. That is, the computer device 700 can be connected to the network 708 through the network interface unit 707 connected to the system bus 705, or the network interface unit 707 can be used to connect to other types of networks or remote computer systems (not shown).

[0139] The memory also includes at least one instruction, at least one program, code set or instruction set, and the at least one instruction, at least one program, code set or instruction set is stored in the memory. The central processing unit 701 implements all or part of the steps in the task scheduling method shown in the above-mentioned embodiments by executing the at least one instruction, at least one program, code set or instruction set.

[0140] Figure 8 The following is a block diagram of a computer device 800 according to an exemplary embodiment of the present application. The computer device 800 may be implemented as the above-mentioned task scheduling device, such as a smart phone, a tablet computer, a notebook computer, a desktop computer, etc. The computer device 800 may also be referred to as a user device, a portable terminal, a laptop terminal, a desktop terminal, or other names.

[0141] Typically, the computer device 800 includes a processor 801 and a memory 802 .

[0142] In some embodiments, the computer device 800 may further optionally include: a peripheral device interface 803 and at least one peripheral device. The processor 801, the memory 802 and the peripheral device interface 803 may be connected via a bus or a signal line. Each peripheral device may be connected to the peripheral device interface 803 via a bus, a signal line or a circuit board. Specifically, the peripheral device includes: at least one of a radio frequency circuit 804, a display screen 805, a camera assembly 806, an audio circuit 807 and a power supply 808.

[0143] In some embodiments, the computer device 800 further includes one or more sensors 809 , including but not limited to: an acceleration sensor 810 , a gyroscope sensor 811 , a pressure sensor 812 , an optical sensor 813 , and a proximity sensor 814 .

[0144] Those skilled in the art will understand that Figure 8 The structure shown in the figure does not constitute a limitation on the computer device 800, and the computer device 800 may include more or less components than those shown in the figure, or combine some components, or adopt a different arrangement of components.

[0145] In an exemplary embodiment, a computer-readable storage medium is also provided, in which at least one computer program is stored, and the computer program is loaded and executed by a processor to implement all or part of the steps in the above-mentioned task scheduling method. For example, the computer-readable storage medium can be a read-only memory (ROM), a random access memory (RAM), a compact disc (CD-ROM), a magnetic tape, a floppy disk, an optical data storage device, etc.

[0146] In an exemplary embodiment, a computer program product is also provided, the computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, when the program instructions are executed by a computer, the computer is executed to implement the above Figure 1 or Figure 4 All or part of the steps of the task scheduling method shown in any embodiment.

[0147] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the claims.

[0148] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

Claims

1. A task scheduling method, characterized in that: The method comprises: Executing the predecessor task through the work processor to obtain a return value of the predecessor task; Determine the subsequent tasks of the preceding task in accordance with the order of the task scheduling template; the task scheduling template is used to define the execution flow of the business processing work class and the relationship between the return value of the preceding task and the task type of the subsequent task; In a case where the subsequent task determined based on the return value of the predecessor task is an asynchronous task, the subsequent task is executed by an asynchronous processor.

2. The method according to claim 1, characterized in that The executing the subsequent task by the asynchronous processor comprises: In the case where the call type corresponding to the subsequent task is a work set call, obtaining a work set associated with the subsequent task; the work set includes at least two mutually related work tasks; The work tasks in the work set are executed by the asynchronous processor according to the scheduling logic indicated by the work set.

3. The method according to claim 2, characterized in that The work set includes mutually nested work tasks and sub-work sets; wherein, mutually nested means that a work task has a corresponding sub-work set, and the sub-work set includes at least two mutually related work tasks.

4. The method according to claim 2, characterized in that: The work set includes the execution order of each interrelated work task and / or dependency conditions.

5. The method according to claim 2, characterized in that: The executing the subsequent task by the exception handler includes: In the case where the call type corresponding to the subsequent task is a work call, the work task corresponding to the subsequent task is executed.

6. The method according to claim 1, characterized in that The task scheduling template is also used to define the relationship between the task execution progress and the task execution order; the method also includes: monitoring the task execution progress in the work processor in real time; The subsequent task is determined according to the relationship between the task execution progress and the task execution order indicated by the task scheduling template.

7. A task scheduling device, characterized in that: The device comprises: A first task execution module, used for executing a predecessor task through a work processor to obtain a return value of the predecessor task; A task determination module, used to determine the subsequent tasks of the predecessor task in accordance with the order of the task scheduling template; the task scheduling template is used to define the execution process of the business processing work class and the relationship between the return value of the predecessor task and the task type of the subsequent task; The second task execution module is used to execute the subsequent task through an asynchronous processor when it is determined that the subsequent task is an asynchronous task based on the return value of the predecessor task.

8. A computer device, characterized in that: The computer device includes a processor and a memory, wherein the memory stores at least one computer program, and the at least one computer program is loaded and executed by the processor to implement the task scheduling method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one computer program, and the computer program is loaded and executed by a processor to implement the task scheduling method according to any one of claims 1 to 6.

10. A computer program product, characterized in that The computer program product comprises a computer program stored on a non-transitory computer-readable storage medium, wherein the computer program comprises program instructions, and when the program instructions are executed by a computer, the computer is caused to execute to implement the task scheduling method as claimed in any one of claims 1 to 6.