Task processing method, device, computer system and computer readable storage medium
The task flow component handles pending tasks in the task flow pipeline chain, and solves the problem that task processing methods rely on business code design in the existing technology, realizing the flexibility and reusability of task processing.
Patent Information
- Application Number
- CN202110085483.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-21
- Publication Date
- 2025-02-21
- Estimated Expiration
- 2041-01-21
AI Technical Summary
In the prior art, task processing methods strongly rely on the design methods of business code, which makes it difficult for the code to be directly reused in different business scenarios. It is necessary to design specific business codes for each business scenario to implement task processing.
By calling the task flow component, pending tasks are assembled into a task flow pipeline chain, and pending tasks in the task flow pipeline chain are processed through the task flow component, including obtaining infix expressions, converting them into suffix expressions and performing operations.
It realizes that tasks can be processed in different business scenarios without targeted design of business code, improves task processing flexibility and reusability, and reduces the work burden of developers.
Smart Images

Figure CN113760262B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and more specifically, to a task processing method, a task processing device, a computer system, a computer-readable storage medium, and a computer program product. Background Art
[0002] Business implementation in the computer field is usually manifested as task processing. Therefore, for different business scenarios, it is inevitable to build a suitable task processing method for each scenario.
[0003] In the process of realizing the concept of the present disclosure, the inventors found that there are at least the following problems in the related technology: the task processing method is usually strongly dependent on the design method of the business code, and the design at the code level is difficult to be directly reused in different business scenarios, resulting in the need to design business codes specifically for each business scenario to implement task processing. Summary of the invention
[0004] In view of this, the present disclosure provides a task processing method, a task processing device, a computer system, a computer-readable storage medium, and a computer program product.
[0005] One aspect of the present disclosure provides a task processing method, comprising: calling a task flow component; assembling at least one to-be-processed task into a task flow pipeline chain based on the task flow component, wherein the task flow pipeline chain includes at least one chain node, and each of the chain nodes corresponds to one of the to-be-processed tasks; and processing the to-be-processed tasks in the task flow pipeline chain through the task flow component.
[0006] According to an embodiment of the present disclosure, the to-be-processed task includes a task event having a logical relationship, and processing the to-be-processed task in the task flow pipeline chain by the task flow component includes: obtaining an infix expression corresponding to the to-be-processed task; converting the infix expression into a postfix expression; and
[0007] The suffix expression is operated to realize the processing of the task to be processed.
[0008] According to an embodiment of the present disclosure, the to-be-processed tasks include a plurality of target task events associated by a target logical operator, and processing the to-be-processed tasks in the task flow pipeline chain through the task flow component includes: determining the execution mode of the plurality of target task events according to the target logical operator; determining the plurality of target task events as a plurality of task events executed in parallel when the target logical operator represents that the execution order of the plurality of target task events is unlimited; and determining the plurality of target task events as a plurality of task events executed in serial when the target logical operator represents that the execution order of the plurality of target task events is limited.
[0009] According to an embodiment of the present disclosure, processing the pending tasks in the task flow pipeline chain through the task flow component includes: obtaining a thread pool when the pending tasks include multiple task events executed in parallel; and simultaneously processing the multiple task events executed in parallel through the thread pool.
[0010] According to an embodiment of the present disclosure, processing the pending tasks in the task flow pipeline chain through the task flow component includes: when the pending tasks include multiple task events executed in series, processing the multiple task events executed in series separately; and when there is a task event execution failure, terminating the subsequent processing of the multiple task events executed in series.
[0011] According to an embodiment of the present disclosure, the suffix expression includes multiple elements, each of which is a logical operator for characterizing the logical relationship or the task event, and operating the suffix expression includes: obtaining a preset operation corresponding to the logical operator in the suffix expression; and sequentially traversing each element in the suffix expression and performing operations in combination with the first-in-last-out method, including: when the element is a task event, directly pushing it into the stack; when the element is a logical operator, executing the preset operation corresponding to the logical operator.
[0012] Another aspect of the present disclosure provides a task processing device, including: a calling module, used to call a task flow component; an assembling module, used to assemble at least one to-be-processed task into a task flow pipeline chain based on the task flow component, wherein the task flow pipeline chain includes at least one chain node, each of the chain nodes corresponds to one of the to-be-processed tasks; and a processing module, used to process the to-be-processed tasks in the task flow pipeline chain through the task flow component.
[0013] Another aspect of the present disclosure provides a computer system, including: one or more processors; and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the task processing method as described above.
[0014] Another aspect of the present disclosure provides a computer-readable storage medium having computer-executable instructions stored thereon, wherein the instructions are used to implement the task processing method as described above when executed.
[0015] Another aspect of the present disclosure provides a computer program product, which includes computer executable instructions, and when the instructions are executed, are used to implement the task processing method as described above.
[0016] According to an embodiment of the present disclosure, by adopting a calling task flow component; assembling at least one pending task into a task flow pipeline chain based on the task flow component, wherein the task flow pipeline chain includes at least one chain node, and each chain node corresponds to a pending task; and a technical means of processing the pending tasks in the task flow pipeline chain through the task flow component, a task flow component is introduced, and the pending tasks can be directly processed through the task flow component. Since the component is easier to reuse, it at least partially overcomes the technical problem that the design at the code level is difficult to directly reuse in different business scenarios, thereby achieving the technical effect of realizing task processing in different business scenarios without the need for targeted design of business codes. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The above and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:
[0018] Figure 1 An exemplary system architecture to which the task processing method according to an embodiment of the present disclosure can be applied is schematically shown;
[0019] Figure 2 A flowchart schematically shows a task processing method according to an embodiment of the present disclosure;
[0020] Figure 3 A binary tree representation of a task-reward package according to an embodiment of the present disclosure is schematically shown;
[0021] Figure 4 A flowchart for generating an infix expression according to an embodiment of the present disclosure is schematically shown;
[0022] Figure 5 A schematic diagram schematically shows stack changes for performing logical operations on a suffix expression according to an embodiment of the present disclosure;
[0023] Figure 6 The overall process of the task flow component according to the embodiment of the present disclosure is schematically shown;
[0024] Figure 7 The structure diagram of the task flow pipeline chain according to the embodiment of the present disclosure is schematically shown;
[0025] Figure 8 A block diagram schematically shows a task processing device according to an embodiment of the present disclosure; and
[0026] Fig. 9 The block diagram schematically shows a computer system suitable for implementing the task processing method according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0027] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.
[0028] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.
[0029] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.
[0030] In the case of using expressions such as "at least one of A, B, and C, etc.", it should generally be interpreted in accordance with the meaning of the expression generally understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.). In the case of using expressions such as "at least one of A, B, or C, etc.", it should generally be interpreted in accordance with the meaning of the expression generally understood by those skilled in the art (for example, "a system having at least one of A, B, or C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).
[0031] Take a level-breaking platform as an example of a specific business scenario. In this scenario, users can receive rewards by completing tasks on the platform, and there can be complex logical relationships between multiple tasks, multiple rewards, and between tasks and rewards.
[0032] For this platform, its operation process includes: querying the task_reward package information from the data table, then looping each package, and traversing the tasks and rewards in the package, processing them in turn to obtain the results of whether the user has performed the task and whether the reward has been received.
[0033] In the process of realizing the concept of the present disclosure, the inventors found that the operation mode of the above platform is usually implemented in the form of hard coding, resulting in high coupling and poor cohesion between the business codes corresponding to the above platform. Moreover, the hard coding method does not precipitate a component, resulting in the logic code corresponding to the hard coding method being applicable in one scenario, but cannot be reused in other similar scenarios (such as scenarios with other logical relationships).
[0034] In the process of implementing the concept of the present disclosure, the inventors also found that the above hard-coding method cannot flexibly support parallel and serial processing between tasks. Moreover, the order between tasks needs to be stored separately as separate fields, which makes the overall implementation process complicated.
[0035] The embodiment of the present disclosure provides a task processing method, a task processing device, a computer system, a computer readable storage medium and a computer program product. The method includes: calling a task flow component; assembling at least one task to be processed into a task flow pipeline chain based on the task flow component, wherein the task flow pipeline chain includes at least one chain node, each chain node corresponds to a task to be processed; and processing the task to be processed in the task flow pipeline chain through the task flow component.
[0036] Figure 1The exemplary system architecture 100 to which the task processing method according to the embodiment of the present disclosure can be applied is schematically shown. It should be noted that: Figure 1 What is shown is merely an example of a system architecture to which the embodiments of the present disclosure can be applied, in order to help those skilled in the art understand the technical content of the present disclosure, but it does not mean that the embodiments of the present disclosure cannot be used in other devices, systems, environments or scenarios.
[0037] like Figure 1 As shown, the system architecture 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired and / or wireless communication links, etc.
[0038] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients and / or social platform software, etc.
[0039] The terminal devices 101 , 102 , and 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0040] The server 105 may be a server that provides various services, such as a background management server that provides support for websites browsed by users using the terminal devices 101, 102, and 103. The background management server may analyze and process received data such as user requests, and feed back processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.
[0041] It should be noted that the task processing method provided in the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, the task processing device provided in the embodiment of the present disclosure can generally be set in the server 105. The task processing method provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105. Accordingly, the task processing device provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105. Alternatively, the task processing method provided in the embodiment of the present disclosure can also be executed by the terminal devices 101, 102, or 103, or can also be executed by other terminal devices different from the terminal devices 101, 102, or 103. Accordingly, the task processing device provided in the embodiment of the present disclosure can also be set in the terminal devices 101, 102, or 103, or can be set in other terminal devices different from the terminal devices 101, 102, or 103.
[0042] For example, the task to be processed may be originally stored in any one of the terminal devices 101, 102, or 103 (for example, the terminal device 101, but not limited thereto), or stored on an external storage device and imported into the terminal device 101. Then, the terminal device 101 may locally execute the task processing method provided by the embodiment of the present disclosure, or send the task to be processed to other terminal devices, servers, or server clusters, and the other terminal devices, servers, or server clusters that receive the task to be processed may execute the task processing method provided by the embodiment of the present disclosure.
[0043] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.
[0044] Figure 2 The flowchart of the task processing method according to the embodiment of the present disclosure is schematically shown.
[0045] like Figure 2 As shown, the method includes operations S201 to S203.
[0046] In operation S201 , a task flow component is called.
[0047] According to an embodiment of the present disclosure, a task flow component is a custom component (or may be called a part or a control), which may exist in the form of a modular script or an external function, and the script-type or functional-type components may be used by direct calling, or the task flow component may exist in the form of an executable file, and the task flow component may be loaded into the memory by running the executable file or performing relevant environment configuration based on the executable file. The task flow component may be called or loaded in a suitable manner to provide a basis for subsequent processing of tasks based on the task flow component.
[0048] In operation S202, at least one to-be-processed task is assembled into a task flow pipeline chain based on the task flow component, wherein the task flow pipeline chain includes at least one chain node, and each chain node corresponds to a to-be-processed task.
[0049] According to an embodiment of the present disclosure, the pending tasks can be expressed as a plurality of task events associated by logical relationships, or can also be expressed as a single task event without logical relationships, and a plurality of task events without logical relationships at all can be divided into different pending tasks. A chain node in the task flow pipeline chain can correspond to a pending task consisting of a plurality of task events associated with logical relationships, or can correspond to a single task event, and the number of chain nodes can be determined by the number of pending tasks. The task flow component can collect pending tasks (for example, a plurality of task events associated with logical relationships or a single task event without logical relationships), and correspond the collected pending tasks to a chain node respectively, and finally assemble to obtain a task flow pipeline chain, providing a further implementation framework for the task processing process of the task flow component.
[0050] In operation S203, the task to be processed in the task flow pipeline chain is processed by the task flow component.
[0051] According to an embodiment of the present disclosure, the task flow component can be used to process the hot tasks corresponding to each chain node in the task flow pipeline chain. In particular, when the tasks to be processed are multiple task events associated with logical relationships, the task flow component can implement logical processing of the multiple task events and output the processing results.
[0052] According to an embodiment of the present disclosure, in the case where the above-mentioned task to be processed is a plurality of task events associated by logical relationships, the code implementation of the task to be processed may generally include the code implementation of each task event and the code implementation of the logical relationship between the plurality of task events, or may include the logic code implementation of the plurality of task events designed with corresponding logical relationships. Based on the above-mentioned embodiment, the actual processing process of the task to be processed (for example, it may include the logic processing process between the plurality of task events) may be completed by the task flow component, whereby the task event and the actual processing process of the task to be processed may be divided into two independent parts and implemented separately, for example, only the code implementation of each task event in the task to be processed may be written, and the logical relationship between the plurality of task events may be stored in the form of a logical expression, and finally the processing of the task to be processed by the task flow component may be realized by processing the logical expression using the above-mentioned task flow component.
[0053] Through the above-mentioned embodiments of the present disclosure, a task flow component is implemented by adopting the pipeline mode. Through the task flow component, the task processing process (implemented by the task flow component) and the specific task event (business-related code) can be isolated, which is conducive to achieving high cohesion and low coupling between business codes. Therefore, on the basis of effectively ensuring that each task event or pending task can be independently constructed or modified, it is also possible to efficiently realize the processing of different task events with various logical relationships. On this basis, the task flow component is particularly suitable for collecting and processing pending tasks composed of task events with complex logical relationships. At the same time, since the component itself is reusable, the task flow component can be applied to any business scenario with complex business logical relationships.
[0054] Taking the level-breaking platform as an example, the task_reward package is generated as the above-mentioned task to be processed according to the logical relationship between the task and the reward in the level-breaking process, combined with the specific embodiment, and referring to Figure 3 to Figure 7 ,right Figure 2 The method shown is further explained.
[0055] It should be noted that Figure 2 The method described can directly process the task to be processed, so when executing Figure 2 Before the method is described, it is necessary to first obtain the tasks to be processed. In this embodiment, for example, the business developer may first create a task_reward package so that subsequent task flow components can obtain the task_reward package.
[0056] According to an embodiment of the present disclosure, when creating a task_reward package, each task reward package can be mapped into a binary tree, which can reflect the task events in the task_reward package (for example, it may include tasks or rewards) and the logical relationship between task events, for example, it can reflect the logical relationship between tasks and tasks, rewards and rewards, tasks and rewards, as well as the sequence between tasks, the mutually exclusive relationship between rewards, which rewards can be obtained by completing which tasks, etc.
[0057] Figure 3 A binary tree representation of a task-reward package according to an embodiment of the present disclosure is schematically shown.
[0058] like Figure 3 As shown, for example, it is a binary tree corresponding to a task_reward package created by a business developer for analyzing a task_reward scheme that needs to be implemented in a certain level-breaking platform. The task_reward scheme is, for example, as follows: executing task 1 or task 2, and executing task 3, and executing task 4 or task 5, you can receive reward 1 or reward 2, and the order of tasks 1 to 3 needs to satisfy: task 3 can be executed only after completing task 1 or task 2, and task 4 or task 5 can be executed only after completing task 3. The method of receiving reward 1 and reward 2 also needs to satisfy: reward 2 cannot be received if reward 1 is received.
[0059] After the business developer completes the code implementation of each task event in the business scenario and determines the logic implementation between multiple task events, the above operations S201 to S203 can be combined to complete a complete business scenario with practical application significance.
[0060] According to the above-mentioned embodiments of the present disclosure, for example, after completing the code implementation of the tasks and rewards in the level-breaking platform and creating a task_reward package that meets the needs of the platform, the above-mentioned task flow component can be introduced to realize the normal operation of the level-breaking platform. With the support of the task flow component, users (or consumers) can log in to the platform to perform corresponding level-breaking tasks and obtain corresponding rewards after successfully completing the level-breaking tasks.
[0061] Based on the above embodiment, when the task to be processed is a task event with a logical relationship (that is, it can be mapped into a binary tree), the above operation S203 includes operations S203 - 1 to S203 - 3.
[0062] In operation S203 - 1 : an infix expression corresponding to the task to be processed is obtained.
[0063] According to an embodiment of the present disclosure, the above infix expression is, for example, saved when a business developer creates a task_reward package.
[0064] Figure 4The flowchart of generating an infix expression according to an embodiment of the present disclosure is schematically shown.
[0065] like Figure 4 As shown, the process includes operations S401 to S403.
[0066] In operation S401, a task_reward package is created.
[0067] According to an embodiment of the present disclosure, the task_reward package in the operation is still taken as an example of the task_reward package created for the aforementioned task_reward scheme. The business developer creates a task_reward package to meet the business needs (i.e., the aforementioned task_reward scheme). The task_reward package can be mapped into a binary tree (e.g., Figure 3 shown).
[0068] In operation S402, an infix expression of the task_reward package is generated.
[0069] According to the embodiments of the present disclosure, the infix expression can clearly represent the logical relationship between the task and the reward in the task_reward package. To facilitate the understanding and calculation of business developers, the infix expression of a binary tree is used to represent the logical relationship of the task_reward package, as follows:
[0070] ((Task 1||Task 2)&&(Task 3&&(Task 4||Task 5)))&&(Reward 1||Reward 2),
[0071] The infix expression is the result of the in-order traversal of the binary tree. By separating each node with a space when traversing the binary tree in-order and adding parentheses () to each subtree, the infix expression corresponding to the task_reward package can be generated.
[0072] In operation S403, the infix expression is stored.
[0073] According to an embodiment of the present disclosure, a mapping relationship between a task_reward package and its corresponding infix expression is constructed, and the infix expression is stored in a database, so that when the task reward package (task to be processed) is subsequently processed, the corresponding infix expression can be obtained according to the mapping relationship.
[0074] In operation S203 - 2 : the infix expression is converted into a postfix expression.
[0075] According to the embodiments of the present disclosure, in order to facilitate the understanding and calculation of business developers, the tasks to be processed are stored in the form of infix expressions, but in order to facilitate the calculation of computers, it is necessary to use postfix expressions for calculation. Therefore, after obtaining an infix expression, it is necessary to convert it into a postfix expression. The conversion process can be implemented, for example, by traversing a binary tree, or it can also be combined with a last-in-first-out queue (stack) and implemented through the following conversion steps:
[0076] a. Define symbols, their priorities, and their corresponding operations as shown in Table 1:
[0077] Table 1
[0078]
[0079] b. Traverse each element of the infix expression from left to right. If it is the above symbol, perform the operation corresponding to the symbol, otherwise add the element to the postfix expression.
[0080] c. Traverse the elements in the stack, pop the top of the stack and add it to the suffix expression until the stack is empty.
[0081] Through the above operations a to c, for example, the infix expression generated in the above operation S402 can be converted into the following postfix expression:
[0082] Task 1 Task 2||Task 3 Task 4 Task 5||&&&&Reward 1 Reward 2||&&.
[0083] In operation S203 - 3 : the suffix expression is operated to implement the processing of the task to be processed.
[0084] According to an embodiment of the present disclosure, the suffix expression may include, for example, a plurality of elements, each of which is a logical operator or a task event for characterizing a logical relationship, and the operation S203-3 may include, for example: obtaining a preset operation corresponding to the logical operator in the suffix expression; and sequentially traversing each element in the suffix expression and performing operations in combination with a first-in, last-out stack. The sequential traversal process may include, for example: directly pushing an element into the stack when the element is a task event; and executing a preset operation corresponding to the logical operator when the element is a logical operator.
[0085] According to the above embodiment of the present disclosure, taking the suffix expression obtained in operation S203-2 as an example, the logical operators used to characterize the logical relationship may include "||", "&&", and the task events may include task 1, task 2, task 3, reward 1, and reward 2. In this embodiment, for example, the FIFO queue (stack) may be used to process and calculate the suffix expression through the following operations:
[0086] a. Create a NamedPredicate class
[0087] The NamedPredicate class implements the Predicate functional interface (java8 lambda expression API). It has its own attribute name, which is used to identify each prediction.
[0088] b. Create a stack
[0089] The type of elements stored in the stack can be, for example, an instance of NamedPredicate, and can implement the test method of NamedPredicate.
[0090] c. Create symbols and corresponding operations as shown in Table 2
[0091] Table 2
[0092]
[0093] d. Traverse the elements of the suffix expression
[0094] If the element is a symbol, the operation corresponding to the symbol is performed.
[0095] Otherwise, construct a NamedPredicate and push it onto the stack.
[0096] e. Perform logical operations
[0097] Figure 5 The diagram schematically shows the stack changes of the postfix expression performing the logical operation according to the embodiment of the present disclosure.
[0098] like Figure 5 As shown, the logical operation is, for example, a stack operation, and ultimately there is only one element in the stack.
[0099] f. Pop the top element of the stack and calculate
[0100] go through Figure 5 The stack operation shown in the figure finally pops the top element of the stack and performs the operation, and calls the test methods of all NamedPredicates in sequence to get the final result.
[0101] According to the above-mentioned embodiments of the present disclosure, the final result may be, for example, the execution result of one or more tasks (for example, success or failure), or whether a reward can be received, or the category of the reward that can be received (for example, including reward 1 and reward 2).
[0102] Through the above-mentioned embodiments of the present disclosure, since only one logical expression is needed to realize the sequence of task events (such as the tasks and rewards in the above-mentioned task_reward package), there is no need for a separate field to store the sequence of tasks and rewards in the task_reward package. For example, in the above-mentioned embodiments, a binary tree infix expression is used to store complex logical relationships, and then a binary tree postfix expression operation is used in combination with the function of the above-mentioned task flow component, thereby reducing the workload of developers.
[0103] According to an embodiment of the present disclosure, the above-mentioned task to be processed includes multiple target task events associated by a target logical operator. The above-mentioned operation S203 may also include, for example: determining the execution mode of the multiple target task events according to the target logical operator; when the target logical operator represents that the execution order of the multiple target task events is unlimited, determining the multiple target task events as multiple task events executed in parallel; and when the target logical operator represents that the execution order of the multiple target task events is limited, determining the multiple target task events as multiple task events executed in serial.
[0104] According to a specific embodiment of the present disclosure, the target logical operator may be, for example, "!", "||" or "&&", where "||" may represent that the execution order of multiple target task events connected thereto is unlimited, and "&&" may represent that the execution order of multiple target task events connected thereto is limited. Then, multiple task events connected by "||" may be determined as task events that can be executed in parallel, and multiple task events connected by "&&" may be determined as task events that can only be executed in sequence (i.e., serially). Figure 3 Taking the infix expression corresponding to the binary tree shown as an example, there is no restriction on the execution order of Task 1 and Task 2. Task 1 and Task 2 can be output in parallel and can be executed by the user. However, in order to execute Task 3, Task 1 (Task 2) must be completed first, that is, Task 1 (or Task 2) and Task 3 need to be output serially. The former (Task 1 or Task 2) must be executed before the latter (Task 3) can be executed.
[0105] It should be noted that when judging that the execution order of multiple target task events is unlimited, it is not limited to judging by the logical operator "||". For example, it can also be judged by judging whether the relationship between multiple task events themselves is (whether there is an order restriction). For example, there are multiple tasks that have no logical relationship with each other, but the multiple tasks have a logical relationship with other tasks at the same time. Then the tasks to be processed can be expressed as (task a, task b, task c)&& (task d), and it can be determined that tasks a, task b, and task c are tasks that can be output in parallel (or executed in parallel).
[0106] According to an embodiment of the present disclosure, when the above-mentioned task to be processed includes multiple task events executed in parallel, a thread pool is obtained; and the multiple task events executed in parallel are processed simultaneously by the thread pool.
[0107] According to a specific embodiment of the present disclosure, taking the above-mentioned task_reward package as an example, when there are multiple task events (tasks or rewards) that can or need to be calculated in parallel (may include output or execution), a thread pool is constructed to obtain the results of all tasks and rewards in parallel (to determine whether the task has been completed and whether the reward has been received).
[0108] According to an embodiment of the present disclosure, when the above-mentioned task to be processed includes multiple task events executed serially, the multiple task events executed serially are processed separately; and when there is a task event execution failure, the subsequent processing of the multiple task events executed serially is terminated.
[0109] According to a specific embodiment of the present disclosure, still taking the above-mentioned task_reward package as an example, when multiple task events (tasks or rewards) must be calculated serially (which may include output or execution), the results of the tasks and rewards are obtained in sequence for the elements (tasks or rewards) in the infix expression corresponding to the task_reward package.
[0110] It should be noted that, no matter in parallel or serial, the calculation of the final result needs to go through the aforementioned operations S203 - 1 to S203 - 3.
[0111] Through the above-mentioned embodiments of the present disclosure, since parallel and serial processing can be flexibly supported, it can be applicable to the processing of task events existing in any manner in various scenarios.
[0112] Based on the above embodiments, Figure 6 The overall process of the task flow component according to an embodiment of the present disclosure is schematically shown.
[0113] like Figure 6 As shown, operations S601 to S605 are included.
[0114] In operation S601, information of a user who logs in to the platform is obtained.
[0115] In operation S602, a task_reward package that the user can choose to perform is obtained based on the user information.
[0116] In operation S603 , a task flow pipeline chain is dynamically assembled.
[0117] According to an embodiment of the present disclosure, this operation may correspond to the above-mentioned operation S202, for example.
[0118] Figure 7 The structure diagram of the task flow pipeline chain according to an embodiment of the present disclosure is schematically shown.
[0119] According to an embodiment of the present disclosure, the above operations S602 to S603 can be performed, for example, by finding out the task_reward package and the infix expression corresponding to each task_reward package according to the user, and constructing a pipelineChain (i.e., the above task flow pipeline chain). Each handler in the pipelineChain (i.e., the above chain node) corresponds to a task_reward package, i.e., corresponds to a binary tree. The constructed pipelineChain is as follows: Figure 7 shown.
[0120] In operation S604, processing is performed on each chain node in the pipeline chain.
[0121] According to an embodiment of the present disclosure, this operation may correspond to the above-mentioned operation S203, for example. In this operation, two processing modes, parallel and serial, may be supported. Applied to actual scenarios, if the order of task events needs to be limited, the serial processing mode may be selected to process the handler, which means that subsequent tasks can only be completed after the previous tasks are completed; if there is no order between task events, the parallel processing mode may be selected to process the handler, which means that the order of tasks is not important, and logical operations are performed after the status of all tasks are obtained.
[0122] In operation S605, the final result is returned.
[0123] According to an embodiment of the present disclosure, the final result can be obtained according to the processing result of operation S604.
[0124] Through the above-mentioned embodiments of the present disclosure, high cohesion and low coupling between business codes are achieved by adopting the pipeline mode and binary tree technology; the task flow component is realized by the pipeline mode, which can be applied to various business scenarios and effectively realize component reuse; the elements in each chain node in the pipeline chain can be processed in parallel to improve performance, or can be processed in serial to support short circuiting, such as if the previous task is not completed, the subsequent task must not be executed; the binary tree structure is used to store the logical relationship between elements, infix expressions are used for storage, and postfix expressions are used for calculation, which is applicable to both serial and parallel processing processes, reducing the workload of developers.
[0125] Figure 8 The block diagram schematically shows a task processing device according to an embodiment of the present disclosure.
[0126] like Figure 8 As shown, the task processing device 800 includes a calling module 810 , an assembling module 820 , and a processing module 830 .
[0127] The calling module 810 is used to call the task flow component.
[0128] The assembling module 820 is used to assemble at least one to-be-processed task into a task flow pipeline chain based on the task flow component, wherein the task flow pipeline chain includes at least one chain node, and each chain node corresponds to a to-be-processed task.
[0129] The processing module 830 is used to process the pending tasks in the task flow pipeline chain through the task flow component.
[0130] According to an embodiment of the present disclosure, the above-mentioned task to be processed includes task events having a logical relationship, and the above-mentioned processing module includes a first acquisition submodule, a conversion submodule and an operation submodule.
[0131] The first acquisition submodule is used to acquire the infix expression corresponding to the task to be processed.
[0132] The conversion submodule is used to convert infix expressions into postfix expressions.
[0133] The operator module is used to operate on the suffix expression to realize the processing of the task to be processed.
[0134] According to an embodiment of the present disclosure, the above-mentioned task to be processed includes a plurality of target task events associated by a target logical operator, and the above-mentioned processing module includes a first determining submodule, a second determining submodule and a third determining submodule.
[0135] The first determination submodule is used to determine the execution mode of multiple target task events according to the target logical operator.
[0136] The second determination submodule is used to determine that the multiple target task events are multiple task events executed in parallel when the target logical operator represents that the execution order of the multiple target task events is unlimited.
[0137] The third determination submodule is used to determine that the multiple target task events are multiple task events executed in series when the target logical operator represents that the execution order of the multiple target task events is restricted.
[0138] According to an embodiment of the present disclosure, the above-mentioned processing module includes a second acquisition submodule and a first processing submodule.
[0139] The second acquisition submodule is used to acquire the thread pool when the task to be processed includes multiple task events executed in parallel.
[0140] The first processing submodule is used to simultaneously process multiple task events executed in parallel through a thread pool.
[0141] According to an embodiment of the present disclosure, the processing module includes a second processing submodule and a termination submodule.
[0142] The second processing submodule is used to process the multiple task events executed serially respectively when the task to be processed includes multiple task events executed serially.
[0143] The termination submodule is used to terminate the subsequent processing of multiple task events executed in series when there is a task event execution failure.
[0144] According to an embodiment of the present disclosure, the above-mentioned suffix expression includes multiple elements, each element is a logical operator or a task event for characterizing a logical relationship, and the above-mentioned operation submodule includes an acquisition unit and an operation unit.
[0145] The acquisition unit is used to obtain the preset operation corresponding to the logical operator in the suffix expression.
[0146] The operation unit is used to sequentially traverse each element in the suffix expression and perform operations in combination with the first-in-last-out operation.
[0147] The computing unit may further include a stacking subunit and an execution subunit.
[0148] The stacking subunit is used to directly stack the element when it is a task event;
[0149] The execution subunit is used to execute the preset operation corresponding to the logical operator when the element is a logical operator.
[0150] According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits, or at least part of the functions of any one of them can be implemented in one module. According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits can be split into multiple modules for implementation. According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits can be at least partially implemented as hardware circuits, such as field programmable gate arrays (FPGAs), programmable logic arrays (PLAs), systems on chips, systems on substrates, systems on packages, application specific integrated circuits (ASICs), or can be implemented by hardware or firmware in any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware, and firmware, or in any appropriate combination of any of them. Alternatively, according to the embodiments of the present invention, one or more of the modules, submodules, units, and subunits can be at least partially implemented as computer program modules, and when the computer program modules are run, the corresponding functions can be performed.
[0151] For example, any multiple of the calling module 810, the assembling module 820, and the processing module 830 can be combined in one module / submodule / unit / subunit for implementation, or any one of the modules / submodules / units / subunits can be split into multiple modules / submodules / units / subunits. Alternatively, at least part of the functions of one or more modules / submodules / units / subunits in these modules / submodules / units / subunits can be combined with at least part of the functions of other modules / submodules / units / subunits and implemented in one module / submodule / unit / subunit. According to an embodiment of the present disclosure, at least one of the calling module 810, the assembling module 820, and the processing module 830 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware, and firmware or in a suitable combination of any of them. Alternatively, at least one of the calling module 810, the assembling module 820, and the processing module 830 may be at least partially implemented as a computer program module, and when the computer program module is executed, the corresponding function may be performed.
[0152] It should be noted that the task processing device part in the embodiment of the present disclosure corresponds to the task processing method part in the embodiment of the present disclosure. The description of the task processing device part specifically refers to the task processing method part, which will not be repeated here.
[0153] Fig. 9 The block diagram schematically shows a computer system suitable for implementing the task processing method according to an embodiment of the present disclosure. Fig. 9 The computer system shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0154] like Fig. 9 As shown, the computer system 900 according to the embodiment of the present disclosure includes a processor 901, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 902 or the program loaded from the storage part 908 to the random access memory (RAM) 903. The processor 901 may include, for example, a general-purpose microprocessor (such as a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (for example, an application-specific integrated circuit (ASIC)), etc. The processor 901 may also include an onboard memory for caching purposes. The processor 901 may include a single processing unit or multiple processing units for performing different actions of the method flow according to the embodiment of the present disclosure.
[0155] In RAM 903, various programs and data required for the operation of system 900 are stored. Processor 901, ROM 902 and RAM 903 are connected to each other through bus 904. Processor 901 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 902 and / or RAM 903. It should be noted that the program can also be stored in one or more memories other than ROM 902 and RAM 903. Processor 901 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in the one or more memories.
[0156] According to an embodiment of the present disclosure, the system 900 may further include an input / output (I / O) interface 905, which is also connected to the bus 904. The system 900 may further include one or more of the following components connected to the I / O interface 905: an input section 906 including a keyboard, a mouse, etc.; an output section 907 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN card, a modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as needed. A removable medium 911, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 910 as needed, so that a computer program read therefrom is installed into the storage section 908 as needed.
[0157] According to an embodiment of the present disclosure, the method flow according to an embodiment of the present disclosure can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program contains a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 909, and / or installed from the removable medium 911. When the computer program is executed by the processor 901, the above-mentioned functions defined in the system of the embodiment of the present disclosure are executed. According to an embodiment of the present disclosure, the system, equipment, device, module, unit, etc. described above can be implemented by a computer program module.
[0158] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.
[0159] According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium. For example, it may include, but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, apparatus, or device.
[0160] For example, according to an embodiment of the present disclosure, the computer-readable storage medium may include the ROM 902 and / or the RAM 903 described above and / or one or more memories other than the ROM 902 and the RAM 903 .
[0161] An embodiment of the present disclosure also includes a computer program product, which includes a computer program, and the computer program contains program code for executing the method provided by the embodiment of the present disclosure. When the computer program product runs on an electronic device, the program code is used to enable the electronic device to implement the task processing method provided by the embodiment of the present disclosure.
[0162] When the computer program is executed by the processor 901, the above functions defined in the system / device of the embodiment of the present disclosure are executed. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0163] In one embodiment, the computer program may be based on a tangible storage medium such as an optical storage device, a magnetic storage device, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of a signal on a network medium, and downloaded and installed through the communication part 909, and / or installed from a removable medium 911. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0164] According to an embodiment of the present disclosure, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect through the Internet).
[0165] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram may represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box may also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions. It can be understood by those skilled in the art that the features recorded in the various embodiments and / or claims of the present disclosure can be combined and / or combined in a variety of ways, even if such a combination or combination is not explicitly recorded in the present disclosure. In particular, without departing from the spirit and teaching of the present disclosure, the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways. All of these combinations and / or combinations fall within the scope of the present disclosure.
[0166] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above separately, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. The scope of the present disclosure is defined by the attached claims and their equivalents. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.
Claims
1. A task processing method, comprising: Call the task flow component; Assembling at least one to-be-processed task into a task flow pipeline chain based on the task flow component, wherein the task flow pipeline chain includes at least one chain node, each of the chain nodes corresponds to one of the to-be-processed tasks, and the to-be-processed tasks include a plurality of target task events associated by a target logical operator; and Processing the pending tasks in the task flow pipeline chain by the task flow component includes: Obtaining an infix expression corresponding to the task to be processed; converting the infix expression into a postfix expression; and The suffix expression is operated to realize the processing of the task to be processed.
2. The method according to claim 1, wherein: Processing the pending tasks in the task flow pipeline chain by the task flow component includes: Determining execution modes of the plurality of target task events according to the target logical operator; In a case where the target logical operator represents that the execution order of the multiple target task events is unlimited, determining the multiple target task events to be multiple task events executed in parallel; and In a case where the target logical operator represents that the execution order of the multiple target task events is restricted, the multiple target task events are determined to be multiple task events executed in series.
3. The method according to claim 1, wherein: Processing the pending tasks in the task flow pipeline chain by the task flow component includes: In the case where the task to be processed includes multiple task events executed in parallel, obtaining a thread pool; and The multiple task events executed in parallel are processed simultaneously by the thread pool.
4. The method according to claim 1, wherein: Processing the pending tasks in the task flow pipeline chain by the task flow component includes: In the case where the task to be processed includes a plurality of task events executed in series, the plurality of task events executed in series are processed separately; and In the case that there is a task event execution failure, the subsequent processing of the multiple task events executed in series is terminated.
5. The method according to claim 1, wherein: The suffix expression includes a plurality of elements, each of which is a logical operator or a task event for representing a logical relationship. The operation on the suffix expression includes: Obtaining a preset operation corresponding to the logical operator in the suffix expression; and Sequentially traverse each element in the suffix expression and perform operations in combination with the first-in, last-out operation, including: When the element is a task event, it is directly pushed into the stack; When the element is a logical operator, a preset operation corresponding to the logical operator is performed.
6. The method according to claim 1, wherein: Assembling at least one to-be-processed task into a task flow pipeline chain based on the task flow component comprises: Acquire the at least one task to be processed, wherein each of the tasks to be processed includes a plurality of task events associated by logical relationships or a single task event without logical relationships; Each of the tasks to be processed is regarded as a chain node; and The at least one to-be-processed task is assembled to obtain the task flow pipeline chain.
7. The method according to claim 1, wherein: The task flow component includes at least one of a modular script, a function, and an executable file.
8. A task processing device, comprising: The calling module is used to call the task flow component; an assembling module, configured to assemble at least one to-be-processed task into a task flow pipeline chain based on the task flow component, wherein the task flow pipeline chain includes at least one chain node, each of the chain nodes corresponds to one of the to-be-processed tasks, and the to-be-processed tasks include a plurality of target task events associated by a target logical operator; and A processing module, used to process the pending tasks in the task flow pipeline chain through the task flow component, the processing module comprising: A first acquisition submodule is used to acquire an infix expression corresponding to the task to be processed; a conversion submodule, used to convert the infix expression into a postfix expression; and The operation submodule is used to operate the suffix expression to realize the processing of the task to be processed.
9. A computer system comprising: one or more processors; a memory for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, enables the processor to implement the method according to any one of claims 1 to 7.
11. A computer program product comprising computer executable instructions, which when executed are used to implement the method of any one of claims 1 to 7.
Citation Information
Patent Citations
Task processing method, electronic device, computer equipment and storage medium
CN110659131A