Data processing method and device, computer equipment and storage medium
By comparing task priority in the multi-level approval system and directly outputting high-priority task results, the problem of long wait time in the approval system is solved, and the approval efficiency and user waiting time are improved.
Patent Information
- Application Number
- CN202411405904.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-09
- Publication Date
- 2025-03-25
AI Technical Summary
In a multi-level approval system, users wait for approval results for a long time, and it is difficult for the existing technology to effectively shorten the processing time of output results and improve the approval process efficiency.
By executing multiple tasks in the thread pool and comparing the priority of tasks, if the priority of the current task is higher than the priority of the task in the cache, and there is a higher priority task completed, the result of the current task is directly output without waiting for the other low-priority tasks to be completed.
It shortens the processing time of output results, improves approval efficiency, and reduces the time for users to wait for results.
Smart Images

Figure CN119690602A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data processing technology, and in particular, to a data processing method, apparatus, computer equipment and storage medium. Background Art
[0002] With the continuous development of computer technology, more and more organizations choose to process user business through computers. In the process of processing business, the business approval process is usually involved.
[0003] Users can log in to the approval system through a computer and submit applications in the approval system. The application will be approved by designated approval personnel to decide whether the application submitted by the user is approved. Compared with the approval process of paper documents, executing the approval process through computers can improve approval efficiency and reduce the use of paper documents. Summary of the invention
[0004] The purpose of the present disclosure is to provide a data processing method, apparatus, computer device and storage medium to shorten the processing time of outputting the first result and improve the approval processing efficiency.
[0005] In order to achieve the above object, the present disclosure provides a data processing method, comprising:
[0006] Execute multiple tasks in the thread pool to obtain an execution result of a first task, each task corresponds to a priority, and the first task is a task that has been completed among the multiple tasks;
[0007] When the execution result is a first result, comparing the priority of the task in the first cache with the priority of the first task, the first result being used to block the execution of the task;
[0008] If the priority of the first task is higher than the priority of the tasks in the first cache, the priority of the first task is not the highest priority, and the execution result of the second task exists in the second cache, then the first result is output; the second task is a task that has been completed among the multiple tasks, and the priority of the second task is higher than the priority of the first task.
[0009] In order to achieve the above object, the present disclosure provides a data processing device, including:
[0010] An execution module is configured to execute multiple tasks in the thread pool to obtain an execution result of a first task, each task corresponds to a priority, and the first task is a task that has been completed among the multiple tasks;
[0011] a comparison module configured to compare the priority of the task in the first cache with the priority of the first task when the execution result is a first result, the first result being used to block the execution of the task;
[0012] The judgment module is configured to output the first result if the priority of the first task is higher than the priority of the task in the first cache, the priority of the first task is not the highest priority, and the execution result of the second task exists in the second cache; the second task is a task that has been completed among the multiple tasks, and the priority of the second task is higher than the priority of the first task.
[0013] In order to achieve the above-mentioned purpose, the present disclosure provides a computer device, which includes: a processor and a memory, and the processor is used to execute a computer program stored in the memory to implement the steps of the data processing method proposed in the embodiment of the present disclosure.
[0014] In order to achieve the above objectives, the present disclosure provides a computer-readable storage medium, which stores at least one instruction. When the at least one instruction is executed by a processor, the steps of the data processing method proposed in the embodiment of the present disclosure are implemented.
[0015] In order to achieve the above-mentioned purpose, the present disclosure provides a computer program product, in which instructions are stored. When the computer program product is executed on a computer, the computer implements the steps of the data processing method proposed in the embodiment of the present disclosure.
[0016] Through the above technical scheme, when the execution result of the current first task is the first result of the blocking task execution, the priority of the first task is compared with the priority in the first cache. If the priority of the first task is higher than the priority of the task in the first cache, it means that the priority of the current first task is the task with the highest priority among the tasks that have obtained the first result; then it is further determined whether there is a second task with a higher priority than the first task in the second cache. If so, it means that the second tasks with a higher priority than the first task have been completed. At this time, it can be further determined that the priority of the current first task is the task with the highest priority among the tasks that have obtained the first result. Then, the first result of the first task can be output without waiting for the remaining tasks with lower priority than the first task to output the execution results, thereby shortening the time to output the first result, improving the approval efficiency, and shortening the waiting time for users to wait for the first result.
[0017] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the following specific embodiments, they are used to explain the present disclosure but do not constitute a limitation of the present disclosure. In the accompanying drawings:
[0019] Figure 1 is a flowchart of the steps of a data processing method proposed according to an exemplary embodiment.
[0020] Figure 2 It is a logical schematic diagram of a data processing method proposed according to an exemplary embodiment.
[0021] Figure 3 The diagram is a schematic diagram of a second cache and a first cache according to an exemplary embodiment.
[0022] Figure 4 The invention is a schematic diagram of data transmission among a task pool, a thread pool and a blocking queue according to an exemplary embodiment.
[0023] Figure 5 It is a schematic diagram of obtaining execution results in sequence according to an exemplary embodiment.
[0024] Figure 6 is a flowchart of the steps of a data processing method proposed according to an exemplary embodiment.
[0025] Figure 7 It is a schematic diagram of asynchronously outputting execution results of each task according to an exemplary embodiment.
[0026] Figure 8 It is a schematic diagram of asynchronously outputting execution results of each task according to an exemplary embodiment.
[0027] Fig. 9 It is a schematic diagram of asynchronously outputting execution results of each task according to an exemplary embodiment.
[0028] Fig.10 is a block diagram of a data processing device according to an exemplary embodiment.
[0029] Fig.11 is a block diagram of a computer device according to an exemplary embodiment.
[0030] Fig.12 is a block diagram of a computer device according to an exemplary embodiment. DETAILED DESCRIPTION
[0031] The specific implementation of the present disclosure is described in detail below in conjunction with the accompanying drawings. It should be understood that the specific implementation described herein is only used to illustrate and explain the present disclosure, and is not used to limit the present disclosure.
[0032] Currently, users and approvers log in to the approval system through computers. Users submit applications in the approval system, and the approvers review the applications through the approval system to decide whether the applications submitted by users are approved.
[0033] In some scenarios, the application submitted by the user will be approved by multiple levels of approvers. Only when all the multiple levels of approvers approve the application submitted by the user, the application submitted by the user will be approved; if any of the multiple levels of approvers rejects the application submitted by the user, the application submitted by the user will not be approved.
[0034] In related technologies, the following two solutions can be adopted to implement multi-level approval:
[0035] Solution A, serial approval decision, after the user submits an application in the approval system, the approval parties from low to high levels will approve the application one by one. After the approval of the approval party at the previous low level, the approval party at the next high level will approve it. In this process, each time a user submits an application, it needs to be approved by multiple approval parties at each level, and the user has to wait for a long time for the approval result.
[0036] Solution B, parallel approval decision, after the user submits an application in the approval system, the approvers from the lowest to the highest level can approve the application in parallel, but the time the user waits for the approval result is limited by the longest approval time of the multiple approvers. For example, after the user submits the application, the approval time of approvers A, B and C is 1h, 2h and 3h respectively. Even if approvers A and B review faster, the user still needs to wait for approver C to approve, and still needs to wait 3h to get the approval result. The user still has to wait for a long time for the approval result.
[0037] Based on this, the present disclosure proposes a data processing method. When the execution result of the current first task is the first result of the blocking task execution, the priority of the first task is compared with the priority in the first cache. If the priority of the first task is higher than the priority of the task in the first cache, it means that the priority of the current first task is the task with the highest priority among the tasks that have obtained the first result; then it is further determined whether there is a second task with a higher priority than the first task in the second cache. If so, it means that the second tasks with a higher priority than the first task have been completed. At this time, it can be further determined that the priority of the current first task is the task with the highest priority among the tasks that have obtained the first result. Then, the first result of the first task can be output without waiting for the remaining tasks with lower priority than the first task to output the execution results, thereby shortening the time to output the first result, improving the approval efficiency, and shortening the waiting time for users to wait for the first result.
[0038] Taking the rejection result of the blocking task execution as an example, if the priorities of the user's credit approval task A, the user's asset approval task B and the user's application limit approval task C are reduced in sequence, assuming that the credit approval task A, the asset approval task B and the application limit approval task C output their respective execution results in chronological order, the execution result of the credit approval task A is a pass result, and the execution result of the asset approval task B is a rejection result, if the current first task is the asset approval task B, the priority of the asset approval task B will be compared with the priority of the tasks in the first cache. If the priority of the asset approval task B is higher than the priority of the tasks in the first cache, and the priority of the asset approval task B is not the highest priority, then the asset approval task is preliminarily determined. Task B is the task with the highest priority among the tasks that have received a rejection result. Then, it is determined whether there is a second task with a higher priority than asset approval task B in the second cache. Since credit approval task A has already issued a pass result before asset approval task B, credit approval task A, which has a higher priority than asset approval task B, has already issued an execution result, and the execution result is not a rejection result. Therefore, it is further determined that asset approval task B is the task with the highest priority among the tasks that have received a rejection result, and the rejection result of asset approval task B is output, without having to wait until the application credit approval task C, which has a lower priority than asset approval task B, is completed. This reduces the time users wait for the application credit approval task C to complete the execution result, and improves the approval efficiency of outputting a rejection result.
[0039] Figure 1 A data processing method is proposed according to an exemplary embodiment. The data processing method is applied in a terminal and includes the following steps:
[0040] In step S11, multiple tasks in the thread pool are executed to obtain the execution result of the first task, and each task corresponds to a priority.
[0041] The first task is a task that has been completed among the multiple tasks, and can also be understood as a task that has obtained an execution result among the multiple tasks.
[0042] The thread pool has multiple threads to process multiple tasks in parallel. Multiple threads processing multiple tasks in parallel means that multiple threads process multiple tasks asynchronously at the same time. The multiple processing processes of multiple threads processing multiple tasks are independent of each other and do not have dependencies.
[0043] For example, thread A, thread B and thread C can process task A, task B and task C respectively. The first processing process of thread A processing task A, the second processing process of thread B processing task B, and the third processing process of thread C processing task C are independent of each other. After thread A processes task A, it can get the execution result of task A first, which does not depend on the processing progress of thread B and thread C.
[0044] In some scenarios, taking threads as tasks as an example, different tasks have different processing speeds, which will result in different speeds of obtaining the execution results of the tasks. Therefore, when obtaining the execution results of different tasks, there will be a time sequence, and the execution results of different tasks will be obtained in sequence. It can also be understood that after each task is processed and an execution result is obtained, the execution result will be obtained. The faster the task processing speed, the earlier the execution result of the task will be obtained; the slower the task processing speed, the later the execution result of the task will be obtained. Therefore, the processing progress of each task does not have a dependent relationship.
[0045] See also Figure 4 As shown, multiple threads in the thread pool can obtain multiple tasks from the task pool, and multiple threads can obtain multiple tasks in the task pool at the same time; multiple threads can also obtain the next task after obtaining a task, until all tasks in the task pool are obtained. For example, there are tasks A, B and C in the task pool. After thread A in the thread pool obtains task A, thread B obtains task B; after thread B obtains task B, thread C obtains task C.
[0046] You can define an instance of the thread pool, ThreadPoolExecutor executor. ThreadPoolExecutor is a class in the concurrent.futures module in Python, which is used to create a thread pool. It can specify the number of threads in the thread pool. The thread pool uses a task pool to manage the tasks that need to be executed.
[0047] You can define a list of task pool instances <concurrencytask>tasks=new ArrayList<>()。List <concurrencytask>Represents the creation of an instance of the List interface. ConcurrencyTask is the object type stored in the List; tasks is the variable name of the List interface; new ArrayList<>() is the syntax for creating an ArrayList instance. This instance is used to create an ArrayList named tasks to store objects of the ConcurrencyTask type. For example, it is used to store all tasks. Multiple threads in the thread pool take tasks from the task pool, execute tasks to obtain execution results, and then put the execution results into the blocking queue.
[0048] After the thread processes the task and obtains the execution result, the execution result can be stored in a queue, such as a blocking queue, and then the execution result of the task can be obtained from the blocking queue.
[0049] When the blocking queue is empty, it means that there is no execution result in the blocking queue. At this time, the threads in the thread pool will be blocked until there is an available execution result in the blocking queue, and then the execution result will be obtained from the blocking queue.
[0050] You can define multiple threads in the thread pool to concurrently process asynchronous tasks and put the execution results of the asynchronously processed tasks into an instance of the blocking queue ExecutorCompletionService <taskres>ecs = newExecutorCompletionService<>(executor). ExecutorCompletionService is a class. First, multiple tasks are submitted to the thread pool. Multiple threads in the thread pool execute multiple tasks in parallel. When a thread in the thread pool completes the task, the execution result is placed in the blocking queue. Another thread in the thread pool obtains the execution result from the blocking queue through the take() method or the poll() method. If there is no execution result in the blocking queue, the take() method will block another thread, and the other thread can only wait. When there is an execution result in the blocking queue, the other thread takes out the execution result and executes the priority judgment logic.
[0051] By setting up a blocking queue, the thread will give up obtaining the execution result after waiting for a certain period of time and execute other tasks until there is an available execution result in the blocking queue. At that time, the execution result will be obtained from the blocking queue. This avoids idle waiting of the thread and makes full use of thread resources.
[0052] The execution result includes a first result and a second result. The first result is used to block the execution of the task, for example, it may be a rejection result; the second result is used not to block the execution of the task, for example, it may be a pass result.
[0053] The priority of each task corresponds to an identifier, which is used to indicate the priority of the first task. The higher the priority of the first task, the more important the first task is. The first task is any task among the multiple tasks, and can also be understood as the task that currently outputs the execution result among the multiple tasks.
[0054] For example, the priority identifications of credit approval task A, asset approval task B, and application quota approval task C can be 1, 2, and 3 respectively, and through the identification of each priority, it can be determined that the priority of credit approval task A, the priority of asset approval task B, and the priority of application quota approval task C gradually decrease. Of course, the priority identifications of credit approval task A, asset approval task B, and application quota approval task C can also be 4, 5, and 6 respectively, and through the identification of each priority, it can be determined that the priority of credit approval task A, the priority of asset approval task B, and the priority of application quota approval task C gradually decrease, and the present disclosure does not limit this.
[0055] In the scenario where multiple threads in the thread pool execute multiple tasks asynchronously, although a thread executes a task and outputs an execution result, the priority of the task corresponding to the execution result is unknown. Therefore, a task identifier can be configured for each execution result and task. Different execution results correspond to different task identifiers. The task corresponding to the execution result can be uniquely identified through the task identifier, and the priority of the task can be identified through the priority identifier.
[0056] The task identifier is used to uniquely identify a task and the execution result of the task, and the priority identifier is used to uniquely identify the priority of a task.
[0057] For example, the priority identifiers of credit approval task A, asset approval task B, and application quota approval task C are 1, 2, and 3 respectively, the task identifier corresponding to credit approval task A and the execution result of credit approval task A is M1, the task identifier corresponding to asset approval task B and the execution result of asset approval task B is M2, and the task identifier corresponding to application quota approval task C and the execution result of application quota approval task C is M3. When a certain execution result is output, and the task identifier of the execution result is M2, it can be determined through the task identifier M2 that the output of the execution result is asset approval task B, and then the priority of asset approval task B can be determined through the priority identifier 2 of asset approval task B.
[0058] In step S12, when the execution result is the first result, the priority of the task in the first cache is compared with the priority of the first task.
[0059] Optionally, the priority identifier of the task in the first cache may be compared with the priority identifier of the first task to determine whether the priority of the first task is higher than the priority of the task in the first cache.
[0060] The first result is used to block the execution of the task.
[0061] For example, taking the first result of the first task as a rejection result, when the execution result of the first task is a rejection result, the priority of the task stored in the first cache can be compared with the priority of the first task to determine whether the priority of the first task is higher than the priority of the task stored in the first cache.
[0062] The first cache is used to store the priority of the highest priority task among the tasks that have obtained the first result and the first result of the task. Since the priority of a task can be located by the priority identifier, the first cache stores the priority identifier of the highest priority task among the tasks that have obtained the first result and the first result of the task.
[0063] For example, see Figure 3 As shown, taking the first result being a rejection result as an example, the first cache stores the priority identifier 3 of the task with the highest priority among the tasks that have obtained the rejection result and the rejection result of the task.
[0064] Among them, the instance of the first cache TaskResrefuseTaskRes=null can be defined. TaskRes is the data type of the refuseTaskRes variable; refuseTaskRes is the variable name. This instance indicates that the refuseTaskRes variable is initialized. Initialization means that there is no reference to the task object, which represents a blank. At this time, the first cache has no value null, and is subsequently overwritten and updated by a task with a higher priority. Among them, the purpose of the first cache being overwritten and updated by a rejection result with a higher priority is to record these rejected execution results. Based on the first cache, the rejection result of the task with the highest priority among the tasks that have obtained the rejection result and the priority of the task can be obtained.
[0065] In step S13, if the priority of the first task is higher than the priority of the tasks in the first cache, the priority of the first task is not the highest priority, and the execution result of the second task exists in the second cache, the first result is output.
[0066] The second task is a task that has been completed among the multiple tasks, and can also be understood as a task that has output an execution result among the multiple tasks.
[0067] The second cache is used to store the priorities of tasks that have completed execution and the execution results of tasks, and also to store the priorities of tasks that have output execution results and the execution results of tasks. Figure 3 As shown, each time an execution result output by a task is obtained, it means that the task has completed the execution task, and the priority of the task and the execution result of the task can be stored in the second cache.
[0068] Optionally, when the priority of the first task is higher than the priority of the tasks in the first cache and the priority of the first task is not the highest priority, it can be determined whether there is an execution result of the second task in the second cache, and if there is an execution result of the second task, the first result is output.
[0069] The priority of the task in the first cache is the priority of the task with the highest priority among the tasks that have obtained the first result. If the priority of the first task is higher than the priority of the task in the first cache, it means that the priority of the first task is the task with the highest priority among the tasks that have obtained the first result. At this time, it can be determined whether there is a second task with a higher priority than the first task in the second cache to further determine whether the first task is the task with the highest priority among the tasks that have obtained the first result; if there is an execution result of the second task with a higher priority than the first task, the first result can be output.
[0070] For example, taking the first result as a rejection result, the priority of the task in the first cache is the priority of the task with the highest priority among the tasks that have obtained the rejection result. If the priority of the first task is higher than the priority of the task in the first cache, it means that the priority of the first task is the task with the highest priority among the tasks that have obtained the rejection result. At this time, it can be determined whether there is a second task with a higher priority than the first task in the second cache to further determine whether the first task is the task with the highest priority among the tasks that have obtained the rejection result; if there is an execution result of a second task with a higher priority than the first task, then the execution results of these second tasks with higher priorities are pass results, which can further determine that the first task is the task with the highest priority among the tasks that have obtained the rejection result, and then the rejection result of the first task can be output without waiting for the execution results of the remaining tasks with lower priorities than the first task to be output.
[0071] Among them, the reason why the execution result of the second task with a higher priority than the first task in the second cache is a pass result is: if the execution result of the second task with a higher priority than the first task is a rejection result, the rejection result will be directly output instead of the first task with a lower current priority outputting the rejection result; when the execution result of the second task with a higher priority than the first task is a pass result, the first task with a lower current priority will be executed to obtain the execution result.
[0072] Among them, you can define the instance Map of the second cache<Integer,TaskRes> taskResMap=newHashMap<>(). Map<Integer,TaskRes> It represents creating an instance of a map interface. Integer is the key of the map interface, TaskRes is the value of the map interface; taskResMap is the variable name of the map interface; new HashMap<>() is the syntax for creating a map interface. This instance is used to create a HashMap named taskResMap, which is used to store the mapping relationship between keys and values, such as the mapping relationship between the execution result of a task and the task identifier.
[0073] In some scenarios, for quick approval scenarios, if a user submits a loan application, the approvers in the approval process corresponding to the loan application include approver A, approver B and approver C. Approver A approves the user's application amount. If the user's application amount meets the amount requirement, approver A will approve the user's application; approver B approves the user's assets and income. If the user's assets and income meet the asset requirements, approver B will approve the user's application; approver C approves the user's credit issue. If the user's credit meets the credit requirements, approver C will approve the user's application.
[0074] In this scenario, the approver is the thread, and the task is the approver approving the user's loan qualifications. The execution result of the task includes whether the application is approved and at least one of the reasons for the failure of the application. For example, if the approver A does not approve the user's application, the reason for the failure is that the user's application amount does not meet the amount requirement; if the approver B does not approve the user's application, the reason for the failure is that the user's assets and income do not meet the asset requirements; if the approver C does not approve the user's application, the reason for the failure is that the user's credit does not meet the requirements.
[0075] In addition, the priority indicator indicates the priority of the task, and the priority of the task is positively correlated with the importance of the task. In the above scenario, the priorities of Task A performed by Approver A, Task B performed by Approver B, and Task C performed by Approver C gradually increase, and the corresponding importance of Task A, Task B, and Task C also gradually increases.
[0076] In other scenarios, for the approval scenarios of the barrier type, the approval scenarios of the barrier type refer to filtering out the group of users that meet the approval rules by setting approval rules. The approval scenarios of the barrier type are the approval parties in the approval process corresponding to the online loan credit application, including Approval Party A, Approval Party B and Approval Party C. Approval Party A approves the user's assets. Approval Party A will intercept the application if the user's assets are less than the set assets. If the user's assets are less than the set assets, the online loan credit application cannot be approved; Approval Party B will intercept the application that exceeds the set amount. If the application amount exceeds the set amount, the online loan credit application cannot be approved; Approval Party C will check the user's credit score. If the credit score is lower than the set threshold, it means that the user's credit is low and the application will be rejected.
[0077] In this scenario, the approver is the thread, and the task is the approver approving the user's loan qualifications. The execution result of the task includes whether the application is approved and at least one of the reasons for the failure of the application. For example, if the approver A does not pass the online loan credit application, the reason for the failure of the application is that the user's assets are small; if the approver B does not pass the online loan credit application, the reason for the failure of the application is that the application amount is too large; if the approver C does not pass the online loan credit application, the reason for the failure of the application is that the user's credit score is too low.
[0078] It can be understood that the present disclosure will output the first result of the first task when it is determined that the first task is the task with the highest priority among the tasks that have obtained the first result. The reason is that in the approval process, the higher the priority of the task, the more important it is, and the first result of the most important task will be output first to let the user know the biggest reason for the rejection of the application. The biggest reason is also the reason why the first result is output by the task with the highest priority among the multiple tasks that have obtained the first result.
[0079] For example, taking the first result being a rejection result as an example, for the quick approval scenario, if a user submits a loan application, the tasks in the approval process corresponding to the loan application include application amount approval task A, asset approval task B and credit approval task C. Application amount approval task A is used to approve the user's application amount, asset approval task B is used to approve the user's assets and income, and credit approval task C is used to approve the user's credit issues. If the priorities of application amount approval task A, asset approval task B and credit approval task C gradually increase, and the execution results of the three tasks are all rejection results, since credit approval task C is the task with the highest priority among all tasks that have received rejection results, the rejection result of credit approval task C will be quickly output, informing the user that the biggest reason for failure to pass the application is the credit problem, so that the user can give priority to dealing with credit problems with high severity; after the credit problem is dealt with, if the user applies for a loan again, the priority of asset approval task B is the task with the highest priority among all tasks that have received rejection results, so the rejection result of asset approval task B will be output, and then the user will be notified to deal with asset and income issues..., and so on. The cycle can gradually notify the user of the severity of the rejection result from high to low. After the user has dealt with the rejection result with a higher severity, the rejection result with a lower severity can be gradually dealt with.
[0080] Through the above technical scheme, when the execution result of the first task is the first result, the priority of the first task is not the highest priority, the priority of the first task is higher than the priority of the tasks in the first cache, and there is no execution result of the second task with a higher priority than the first task in the second cache, it is determined that the first task is the task with the highest priority among the tasks that have obtained the first result. At this time, the first result of the first task can be output without waiting for the completion of other tasks with a lower priority than the first task, thereby shortening the time for outputting the first result, shortening the time for users to wait for the output of the execution results of low-level tasks, and improving the approval efficiency.
[0081] An exemplary embodiment related to the present disclosure is introduced below, which is used to explain an exemplary solution in a scenario where there is no execution result of a second task with a higher priority than that of the first task in the second cache.
[0082] If the execution result of the second task does not exist in the second cache, the first result is updated to the first cache.
[0083] If there is no execution result of the second task with a higher priority than the first task in the second cache, it means that the second task with a higher priority than the first task has not been completed, and it is not certain whether the first task is the task with the highest priority among the tasks that have obtained the first result. Therefore, the priority identifier of the first task and the first result of the first task can be updated to the first cache, so that the first cache records the priority identifier of the task with the highest priority among the tasks that have obtained the first result and the first result of the task, and continues to obtain the execution result of the next task.
[0084] For example, if the first cache does not store the priority of the task and the execution result of the task, and the execution result of the first task is the first result, the priority identifier of the first task and the execution result of the first task are updated to the first cache.
[0085] For example, if the first cache stores an identifier of a task priority and a first result of the task, and the priority of the first task is greater than the priority of the task in the first cache, the identifier of the priority in the first cache is updated to the identifier of the priority of the first task, and the first result in the first cache is updated to the first result of the first task.
[0086] Through the above technical solution, the first cache can be updated in real time, so that the first cache stores the priority identifier of the task with the highest priority among the tasks that have obtained the first result and the first result of the task.
[0087] The following describes exemplary embodiments of the present disclosure. Figure 6 As shown, this exemplary embodiment is used to explain an exemplary solution for quickly outputting a first result, comprising the following steps:
[0088] In step S21, when the execution result is the second result, it is determined whether the first result exists in the second cache, and the second result is used to not block the execution of the task.
[0089] The second result is used to not block the execution of the task, for example by passing the result.
[0090] When the execution result of the first task is the second result, it means that the current execution result will not be used as the first result that is finally outputted. At this time, it can be determined whether there is a first result of the task with the highest priority among the tasks that have obtained the first result in the second cache.
[0091] For example, taking the first result as a rejection result and the second result as a pass result, if the execution result of the first task is a pass result, it means that the current pass result will not be used as the final output rejection result. At this time, it can be determined whether there is a rejection result of the highest priority task among the tasks that have already obtained a rejection result in the second cache.
[0092] In step S22, if the first result exists in the second cache, it is determined whether there is an execution result of a third task in the second cache, and the priority of the third task is higher than the priority of the task of the first result.
[0093] For example, taking the first result being rejection result A as an example, if the second cache contains rejection result A output by the task with the highest priority among the tasks that have already obtained rejection results, in order to re-determine whether the priority of the task with rejection result A is the highest priority among the tasks that have already obtained rejection results, it is further possible to determine whether there is an execution result of a third task in the second cache whose priority is higher than the priority of the task corresponding to the rejection result A, thereby further determining whether the rejection result A stored in the second cache is the rejection result with the highest priority among the tasks that have already obtained rejection results.
[0094] In step S23, if the execution result of the third task exists in the second cache, the first result is output.
[0095] For example, if the first result is a pass result and the second result is a reject result, if there is an execution result of a third task in the second cache with a higher priority than the task with reject result A output by the task with the highest priority among the tasks that have obtained a reject result, indicating that the execution result of these third tasks is a pass result, the reject result A of the task with the highest priority in the second cache will be output. Because the execution result of the third task with a higher priority than the reject result A is a reject result, the reject result of the third task will be output in the previous judgment process, and the task corresponding to the reject result A with a lower priority will not be executed.
[0096] During this process, if the execution result of the first task is the second result, and there is a first result output by the task with the highest priority among the tasks that have obtained the first result in the second cache, the priority of the task corresponding to the first result stored in the second cache will be compared with the priorities of the remaining tasks stored in the second cache. If the remaining tasks in the second cache with a higher priority than the task with the first result have already output execution results, it can be further determined that the first result is the first result with the highest priority among the tasks that have obtained the first result. In this case, the first result will be output without waiting for the completion of the remaining tasks with a lower priority than the task corresponding to the first result, thereby reducing the user's waiting time.
[0097] Among them, when the execution result of the first task is the second result and the first result exists in the first cache, the priority of the task corresponding to the first result is compared with the priority of the task stored in the second cache, rather than comparing the priority of the task corresponding to the second result with the priority of the task stored in the second cache. The reason is:
[0098] If the priority of the task corresponding to the second result is compared with the priority of the task stored in the second cache, it may happen that a task with a higher priority than the task of the second result has already produced an execution result, but a task with a higher priority than the task corresponding to the first result has not yet produced an execution result.
[0099] In the embodiment of the present disclosure, each time a first task outputs a second result, the priority of the task corresponding to the first result is uniformly compared with the priority of the task stored in the second cache. Since the first result in the first cache is the first result of the task with the highest priority among the tasks that have obtained the first result, after comparing the priority of the task corresponding to the first result with the priority of the task stored in the second cache, it can be determined whether there is a third task with a higher priority than the task corresponding to the first result that has been completed among the priorities of the tasks stored in the second cache; if there is a third task that has been completed, it can be further determined that the first result is the first result of the task with the highest priority among the tasks that have currently obtained the first result.
[0100] For example, see Figure 5 As shown, taking the first result being a rejection result and the second result being a pass result as an example, if the priorities of task 0, task 1, task 2, task 3, and task 4 gradually decrease, assuming that these five tasks output execution results in the order of task 3, task 1, task 2, task 4, and task 0, and task 3 outputs a rejection result (first result) and task 1 outputs a pass result (second result), if the current pass result of task 1 is compared with the priority of the tasks stored in the second cache, it will be determined whether task 0, which has a higher priority than task 1, has an execution result. If task 0 has already obtained an execution result, the rejection result of task 3 will be output.
[0101] In this scheme, the priority of task 1 is greater than the priority of task 2. Therefore, if the priority of task 1 in the second cache is compared with the priorities of other tasks, it determines whether task 0, which has a higher priority than task 1, has an execution result. It does not determine whether task 2, which has a lower priority than task 1, has an execution result. Even if task 2, which has a lower priority than task 1, does not have an execution result, the rejection result of task 3 obtained previously will be output, resulting in the priority of task 2 not being involved in the comparison.
[0102] However, if task 3 in the second cache (the task corresponding to the first result) is compared with the remaining tasks, and task 2, which has a higher priority than task 3, has not yet produced an execution result, the rejection result of task 3 will not be output until task 2, which has a higher priority than task 3, has produced an execution result, and the execution result is a pass result, then the rejection result of task 3 will be output, which can ensure that the priority of task 2 is involved in the comparison.
[0103] It can be seen that in the scenario where the current task 1 outputs a pass result, the priority of task 3 corresponding to the rejection result recorded in the first cache is compared with the priorities of other tasks in the second cache. If tasks 1, 2, and 0, which have higher priorities than task 3, all output execution results and the execution results are pass results, the rejection result of task 3 will be output, thereby avoiding missing the comparison of the priority of task 2 and making the output rejection result more accurate.
[0104] Every time the execution result is the second result, a self-check will be performed to check whether the remaining tasks in the second cache with a higher priority than the task corresponding to the first result have an execution result. If all of them have an execution result, the rejection result in the output first cache can be accurate and effective.
[0105] In step S24, if the execution result of the third task does not exist in the second cache, the first result is updated to the first cache.
[0106] If there is no execution result of a third task with a higher priority than the task corresponding to the first result in the second cache, the first result and the priority of the task corresponding to the first result can be updated to the first cache, so that the first cache records the first result of the task with the highest priority among the tasks that have obtained the first result, and the priority of the task with the first result, so that when it is subsequently determined whether there is an execution result of the third task in the second cache, the priority of the task corresponding to the first result recorded in the first cache can be compared with the priorities of other tasks stored in the second cache.
[0107] Optionally, if the execution result is the second result, the priority of the task recorded in the first cache can also be compared with the priority of the task stored in the second cache. If there is a third task in the second cache with a higher priority than the task recorded in the first cache, the first result recorded in the first cache is output.
[0108] For example, taking the case where the second result is a rejection result and the first result is a pass result, the priority of the task corresponding to the rejection result recorded in the first cache can be compared with the priority of the task in the second cache. If there is a third task in the second cache with a higher priority than the task corresponding to the rejection result recorded in the first cache and it outputs an execution result, the rejection result recorded in the first cache is output.
[0109] Through the above technical solution, when the execution result of the first task is the second result and the first result exists in the second cache, the priority of the task corresponding to the first result in the second cache will be compared with the priorities of other tasks stored in the second cache. If other tasks in the second cache with a higher priority than the task corresponding to the first result have already output execution results, it can be further determined that the task corresponding to the first result in the second cache is the first result with the highest priority among the tasks that have obtained the first result. In this case, the first result will be output without waiting for the completion of other tasks with a lower priority than the task corresponding to the first result, thereby reducing user waiting time.
[0110] The following is an exemplary embodiment of the present disclosure, which is used to explain an exemplary solution of outputting a second result when the execution results of multiple tasks are all the second result, and includes:
[0111] If the first result does not exist in the second cache, it is determined whether the first task is the last task; if the first task is the last task, the second result is output.
[0112] The absence of the first result in the second cache indicates that the second cache does not have the first result of the task with the highest priority among the tasks that have obtained the first result, which also means that the second cache does not have any first result and stores only second results.
[0113] For example, the first result is a rejection result and the second result is a pass result. If there is no rejection result in the second cache, it means that all the results stored in the second cache are pass results.
[0114] When all the second results are stored in the second cache and the execution result of the current first task is the second result, if the current first task is the last task among the multiple tasks in the first thread, the second result will be output.
[0115] For example, if the first result is a rejection result and the second result is a pass result, and all the results stored in the second cache are pass results, and the execution result of the current first task is a pass result, if the current first task is the last task among multiple tasks, a pass result will be output.
[0116] In some scenarios, for the approval scenarios of fast approval, take the thread as the approver and the task as approval as an example. If a user submits a loan application, the approvers in the approval process corresponding to the loan application include approver A, approver B and approver C. Approver A approves the user's application amount, approver B approves the user's assets and income, and approver C approves the user's credit problem. If the current first task is for approver C to approve the user's credit problem, all the results stored in the second cache are passed, and approver C approves the user's application and determines that the user's credit meets the credit requirements, if approver C's approval of the user's credit problem is the last task to complete the execution of the task, it will output a pass result and approve the user's loan application.
[0117] The blocking queue can be monitored by a thread until the execution result of the last task appears in the blocking queue, and then it is determined that the task is the last task among multiple tasks in the thread pool.
[0118] Through the above technical solution, the second result can be output when all tasks among the multiple tasks are the second result, thereby ensuring that the second result is output when all tasks are passed.
[0119] The following describes an exemplary embodiment of the present disclosure, which is used to explain an exemplary solution for storing the execution result in the second cache, including any of the following solutions:
[0120] (1) When the execution result is the second result, the second result is stored in the second cache.
[0121] The second result and the priority of the task corresponding to the second result may be stored in the second cache in correspondence, and the priority of the task corresponding to the second result may be represented by an identifier of the priority of the task corresponding to the second result.
[0122] For example, the second result is a pass result. When the execution result is a pass result, the pass result and the identifier of the priority of the task corresponding to the pass result are stored in the second cache in correspondence with each other.
[0123] In some cases, see Figure 3 As shown, the second result cached in the second cache and the identifier of the priority of the task corresponding to the second result may be expressed in the form of (identifier, second result). Taking the identifier as 1 and the second result as a pass result as an example, it may be (1, pass).
[0124] (2) When the execution result is the first result, the first result is stored in the second cache.
[0125] The first result and the priority of the task corresponding to the first result may be stored in the second cache in correspondence, and the priority of the task corresponding to the first result may be represented by an identifier of the priority of the task corresponding to the first result.
[0126] For example, the second result is a rejection result. When the execution result is a rejection result, the rejection result and the identifier of the priority of the task corresponding to the rejection result are stored in the second cache in correspondence with each other.
[0127] In some scenarios, the first result stored in the second cache and the identifier of the priority of the task corresponding to the first result may be expressed in the form of (identifier, first result). For example, if the identifier is 2 and the first result is a rejection result, it may be (2, rejection).
[0128] (3) For each execution result obtained, the execution result is stored in the second cache.
[0129] After obtaining the execution result of any first task, the execution result of the first task and the identifier of the priority of the first task are stored in the second cache in correspondence. The execution result includes but is not limited to the first result and the second result mentioned above.
[0130] Optionally, when the priority of the first task is lower than the priority of the tasks in the first cache, the first result of the first task may be stored in the second cache.
[0131] For example, taking the first result as a rejection result, when the priority of the first task is lower than the priority of the tasks in the first cache, the rejection result of the first task may be stored in the second cache.
[0132] Through the above technical solution, for the first result and / or second result obtained, the first result and / or the second result will be stored in the second cache, so that the second cache serves as a container for recording the first result and / or the second result. When the priority comparison is performed subsequently, it can be queried from the second cache whether there are other tasks with higher priority than the task corresponding to the first result, and whether the execution results of other tasks are completed.
[0133] The following describes an exemplary embodiment of the present disclosure, which is used to explain the schemes in different scenarios of enabling the priority comparison function and not enabling the priority comparison function, and includes the following steps:
[0134] (1) Comparison of priority flags to determine whether to enable the task.
[0135] The comparison of the priority identification is a function. After the comparison of the priority identification is enabled, the function is started. If it is not enabled, the function will not be started.
[0136] (2) If the comparison of the priority flags of the tasks is enabled, the priority flags of the tasks in the first cache are compared with the priority flag of the first task.
[0137] If the comparison of the priority identifier is turned on, the above steps S11 to S13 will be executed, and the priority identifier in the first cache will be compared with the priority identifier of the first task. If the priority of the first task is higher than the priority of the task in the first cache, and the priority of the first task is not the highest priority, it is determined whether there is a second task in the second cache whose priority is higher than that of the first task. If so, the first result is output; the above steps S22 to S24 will also be executed, and the priority identifier of the task corresponding to the first result will be compared with the priority identifiers of the remaining tasks in the second cache. If it is determined that there is a third task in the second cache whose priority is higher than that of the task corresponding to the first result, the first result is output.
[0138] It can be seen that after the priority identification comparison is turned on, if the execution result of the current first task output is the first result, the above steps S11 to S13 will be executed to quickly output the first result; if the execution result of the current first task output is the second result, the above steps S22 to S24 will be executed to quickly output the first result.
[0139] (3) If the comparison of the priority identifier of the task is not enabled, the first result is output.
[0140] If the comparison of the task priority flags is not enabled, and the execution result of the first task is the first result, the first result is directly output.
[0141] For example, taking the first result as a rejection result as an example, if the comparison of the priority identification is not enabled, and the execution result of the first task is a rejection result, the rejection result is directly output.
[0142] Through the above technical solution, when the comparison of priority identifiers is turned on, by comparing the priority of the task corresponding to the currently obtained first result with the priorities of the remaining tasks, the first result of the task with the highest priority among the tasks that have obtained the first result can be quickly output, thereby quickly informing the user of the biggest reason why the approval was not passed; when the comparison of priority identifiers is not turned on, if the currently obtained execution result is the first result, the first result is directly output, and any first result among multiple first results can be quickly output, thereby quickly informing the user of any reason why the approval was not passed.
[0143] The following is an exemplary embodiment of the present disclosure, which is used to explain an exemplary solution for quickly outputting a first result, including:
[0144] If the priority of the first task is the highest priority, the first result is output.
[0145] After the execution result of the current first task outputs the first result and before comparing the priority of the first task with the priority of the tasks in the first cache, it can be determined whether the priority of the first task is the highest priority among multiple tasks, and if so, the first result is output.
[0146] For example, after the execution result of the current first task output is a rejection result and before comparing the priority of the first task with the priority of the tasks in the first cache, it can be determined whether the priority of the first task is the highest priority among multiple tasks. If so, the rejection result is output.
[0147] Optionally, if the execution result is the second result, and the priority of the task corresponding to the second result is the highest priority among the priorities of the multiple tasks, the execution result of the next task is obtained.
[0148] In some approval processes, take the case where the second result is a pass result and the first result is a reject result. If the execution results of the tasks in the approval process are all pass results, the user's application will be approved; if the execution result of at least one task in all the tasks in the approval process is a reject result, the user's application will not be approved. Therefore, if the current execution result is a pass result and the priority of the task corresponding to the current execution result is the highest priority, it means that the reject result of the task with the highest priority among the tasks that have received a reject result has not yet appeared. At this time, you can continue to obtain the execution result of the next task until you get the reject result of the task with the highest priority among the tasks that have received a reject result.
[0149] Through the above technical solution, each time the first result is obtained and before the priority of the first task is compared with the priority of the task in the first cache, it is determined whether the priority of the task corresponding to the first result is the highest priority among the priorities of multiple tasks. If it is the highest priority, it means that the first result is the first result of the task with the highest priority among all execution results. In this way, the first result can be output directly without waiting for the completion of other low-priority tasks, thereby realizing the rapid output of the first result; and if it is determined that the first task currently outputting the first result has the highest priority, there is no need to perform task priority judgment, thereby reducing computer computing power.
[0150] The following is an exemplary solution proposed by an exemplary embodiment of the present disclosure. The exemplary solution is used to explain the complete execution process of obtaining the execution result each time. Figure 2 As shown, the priority of the task corresponding to the current execution result can be compared with the priorities of the remaining tasks until the execution result with the highest priority and the first result is obtained.
[0151] If the currently obtained execution result is the first result, the following steps are performed:
[0152] 1. Store the first result in the second cache.
[0153] 2. If the priority judgment is not enabled, the first result currently obtained is output; if the priority judgment is enabled, it is determined whether the task corresponding to the first result is the highest level.
[0154] If it is the highest level, directly output the current first result.
[0155] If it is not the highest level, determine whether the first cache has a value. If not, overwrite the first cache with the current first result. If there is a value, compare the priority of the first task corresponding to the current first result with the priority of the task in the first cache. When the priority of the first task corresponding to the current first result is greater than the priority of the task in the first cache, replace the priority identifier in the first cache with the priority identifier of the first task, and replace the first result in the first cache with the current first result.
[0156] 4. Traverse the second cache to check whether there are values for the second tasks in the second cache that have a higher priority than the updated priority in the first cache. If there are no values, it means that these second tasks have not been completed yet, and the next execution result can be obtained at this time; if there are values, it means that these second tasks have been completed, and the execution results of these second tasks are the second results, then the first result after the current second cache update is directly output.
[0157] If the currently obtained execution result is the second result, the following steps are performed:
[0158] 1. Store the second result in the second cache.
[0159] 2. Determine whether there is a value in the first cache. If there is no value in the first cache, determine whether the current task is the last task. If so, output the second result; if not, obtain the execution result of the next task and enter the loop; if there is a value in the first cache, compare the priority of the task corresponding to the current second result with the priority of the task in the first cache. When the priority of the task corresponding to the current second result is greater than the priority of the task in the first cache, execute the following steps.
[0160] 3. Traverse the second cache to check whether there is a value for the third task in the second cache with a higher priority than the task in the first cache. If there is no value, it means that these third tasks have not been completed. At this time, you can get the execution result of the next task and enter the loop; if there is a value, it means that these third tasks have been completed and are the second result, then directly output the first result of the current first cache record.
[0161] In some scenarios, the first result is a rejection result and the second result is a pass result. Figure 7 As shown, it is assumed that the execution results of the tasks are obtained in the order of task 3, task 2, task 1 and task 0, and the priorities of task 0, task 1, task 2, task 3 and task 4 are gradually reduced.
[0162] When the execution result of Task 3 is obtained for the first time, proceed to the following steps:
[0163] 1. Assuming that the execution result of task 3 is a rejection result, the rejection result of task 3 is first cached in the second cache, and the second cache = {(0, unknown), (1, unknown), (2, unknown), (3, rejection), (4, unknown)}.
[0164] 2. Determine whether Task 3 is the highest priority. If it is not the highest priority, execute the following steps. Since Task 3 is not the highest priority, execute the following steps.
[0165] 3. Determine whether the first cache has a value. If not, update the first cache to (3, reject). Since this is the first time to obtain the task, the first cache has no value, so the first cache can be updated to (3, reject).
[0166] 4. Traverse the second cache to check whether there is a value for the task with a priority greater than priority 3 in the first cache record in the second cache. This is the first time that task 3 is obtained, so the second cache is {(3, rejected)}. Task 2, task 1, and task 0, which have a higher priority than task 3, have not been completed yet. At this time, you can continue to obtain the next task.
[0167] When the execution result of Task 2 is obtained for the second time, proceed to the following steps:
[0168] 1. Assuming that the execution result of task 2 is a pass result, the pass result of task 2 is first cached in the second cache, and the second cache = {(0, unknown), (1, unknown), (2, pass), (3, reject), (4, unknown)}.
[0169] 2. Determine whether the first cache has a value. If the first cache has a value, compare the priority of the first cache with the priority of task 2. Although the priority 2 of task 2 is greater than the priority 3 of the first cache record, the execution result of task 2 is a pass result. At this time, the first cache is not updated, and the first cache is still (3, rejected), and proceed to the next step.
[0170] 3. Traverse the second cache to check whether there is a value for the task in the second cache whose priority is greater than priority 3 recorded in the first cache. Obviously, although task 2 with a higher priority than priority 3 in the second cache has been completed, task 1 and task 0 have not been completed, so you can continue to get the next task.
[0171] When the execution result of Task 1 is obtained for the third time, proceed to the following steps:
[0172] 1. Assuming that the execution result of task 1 is a rejection result, first cache the rejection result of task 1 in the second cache, the second cache = {(0, unknown), (1, rejection), (2, pass), (3, rejection), (4, unknown)}.
[0173] 2. Determine whether Task 1 is the highest priority. If it is not the highest priority, execute the following steps. Since Task 1 is not the highest priority, execute the following steps.
[0174] 3. Determine whether the first cache has a value. If so, compare the priority of the first cache record with the priority of task 1. Since the priority 1 of task 1 is greater than the priority 3 of the first cache record, the priority 3 of the first cache is updated to the priority 1 of task 1.
[0175] 4. Traverse the second cache to check whether there is a value for the task in the second cache whose priority is greater than the priority 1 indicated by the first cache. Obviously, task 0 in the second cache with a higher priority than 1 has not been completed, so you can continue to get the next task.
[0176] When the execution result of task 0 is obtained for the fourth time, proceed to the following steps:
[0177] 1. Assuming that the execution result of task 0 is a rejection result, first cache the rejection result of task 0 in the second cache, the second cache = {(0, rejection), (1, rejection), (2, pass), (3, rejection), (4, unknown)}.
[0178] 2. Determine whether Task 0 is the highest priority. Since Task 0 is the highest priority, directly output the rejection result of Task 0 without waiting for the execution result of Task 4 to be completed.
[0179] It is understandable that the embodiments of the present disclosure also propose a valid set, which stores the execution results of tasks with higher priorities than the first cache record. When there are tasks with rejection results among multiple tasks, the task with the highest priority among the tasks in the valid set that have obtained rejection results is output; for tasks outside the valid set, the execution results of tasks outside the valid set are not considered for output.
[0180] For example, in the above example, after the rejection result of task 3 is obtained for the first time, the valid set is {(0, unknown), (1, unknown), (2, unknown), (3, rejected)}, which does not consider the execution result of task 4; after the passing result of task 2 is obtained for the second time, the valid set remains unchanged; after the rejection result of task 1 is obtained for the third time, the valid set is {(0, unknown), (1, rejected)}, which no longer considers the execution results of tasks 2, 3 and 4; after the passing result of task 0 is obtained for the fourth time, the valid set is {(0, passed), (1, rejected)}, and the rejection result of task 1 with the highest priority among the tasks that have obtained the rejection result in the valid set will be output.
[0181] In some scenarios, the first result is a rejection result and the second result is a pass result. Figure 8 As shown, it is assumed that the execution results of the tasks are obtained in the order of task 3, task 2, task 1 and task 0, and the priorities of task 0, task 1, task 2, task 3 and task 4 are gradually reduced.
[0182] When the execution result of Task 3 is obtained for the first time, proceed to the following steps:
[0183] 1. Assuming that the execution result of task 3 is a pass result, first cache the pass result of task 3 in the second cache, the second cache = {(0, unknown), (1, unknown), (2, unknown), (3, pass), (4, unknown)}.
[0184] 2. Determine whether the first cache has a value. Since the first cache has no value, it can be determined whether the current task 3 is the last task. Since task 3 is not the last task, the next task can be obtained to enter the loop.
[0185] When the execution result of Task 2 is obtained for the second time, proceed to the following steps:
[0186] 1. Assuming that the execution result of task 2 is a pass result, first cache the pass result of task 2 in the second cache, the second cache = {(0, unknown), (1, unknown), (2, pass), (3, pass), (4, unknown)}.
[0187] 2. Determine whether the first cache has a value. Since the first cache has no value, it can be determined whether the current task 2 is the last task. Since task 2 is not the last task, the next task can be obtained to enter the loop.
[0188] When the execution result of Task 1 is obtained for the third time, proceed to the following steps:
[0189] 1. Assuming that the execution result of task 1 is a rejection result, first cache the rejection result of task 1 in the second cache, the second cache = {(0, unknown), (1, rejection), (2, pass), (3, pass), (4, unknown)}.
[0190] 2. Determine whether Task 1 is the highest priority. Since Task 1 is not the highest priority, execute the following steps.
[0191] 3. Determine whether the first cache has a value. If the first cache has no value, update the first cache to (1, reject).
[0192] 4. Traverse the second cache to check whether there is a value for the task with a priority of 1 in the second cache whose priority is greater than that of the first cache record. It is obviously not completed yet than the task 0 with a priority of 1. At this time, you can continue to get the next task.
[0193] When the execution result of task 0 is obtained for the fourth time, proceed to the following steps.
[0194] 1. Assuming that the execution result of task 0 is a rejection result, first cache the rejection result of task 0 in the second cache, the second cache = {(0, rejection), (1, rejection), (2, pass), (3, pass), (4, unknown)}.
[0195] 2. Determine whether Task 0 is the highest priority. Since Task 0 is the highest priority, the rejection result of Task 0 can be output without waiting for the execution result of Task 4 to be completed.
[0196] In some scenarios, the first result is a rejection result and the second result is a pass result. Fig. 9 As shown, it is assumed that the execution results of the tasks are obtained in the order of task 3, task 2, task 1, task 0 and task 4, and the priorities of task 0, task 1, task 2, task 3 and task 4 are gradually reduced.
[0197] When the execution result of Task 3 is obtained for the first time, proceed to the following steps:
[0198] 1. Assuming that the execution result of task 3 is a pass result, first cache the pass result of task 3 in the second cache, the second cache = {(0, unknown), (1, unknown), (2, unknown), (3, pass), (4, unknown)}.
[0199] 2. Determine whether the first cache has a value. Since the first cache has no value, it can be determined whether the current task 3 is the last task. Since task 3 is not the last task, you can continue to obtain the next task.
[0200] When the execution result of Task 2 is obtained for the second time, proceed to the following steps:
[0201] 1. Assuming that the execution result of task 2 is a pass result, first cache the pass result of task 2 in the second cache, the second cache = {(0, unknown), (1, unknown), (2, pass), (3, pass), (4, unknown)}.
[0202] 2. Determine whether the first cache has a value. Since the first cache has no value, it can be determined whether the current task 2 is the last task. Since task 2 is not the last task, you can continue to obtain the next task.
[0203] When the execution result of Task 1 is obtained for the third time, proceed to the following steps:
[0204] 1. Assuming that the execution result of task 1 is a pass result, first cache the rejection result of task 1 in the second cache, the second cache = {(0, unknown), (1, pass), (2, pass), (3, pass), (4, unknown)}.
[0205] 2. Determine whether the first cache has a value. Since the first cache has no value, it can be determined whether the current task 1 is the last task. Since task 1 is not the last task, you can continue to obtain the next task.
[0206] When the execution result of Task 0 is obtained for the third time, proceed to the following steps:
[0207] 1. Assuming that the execution result of task 0 is a pass result, first cache the pass result of task 0 in the second cache, the second cache = {(0, pass), (1, pass), (2, pass), (3, pass), (4, unknown)}.
[0208] 2. Determine whether the first cache has a value. Since the first cache has no value, it can be determined whether the current task 0 is the last task. Since task 0 is not the last task, you can continue to obtain the next task.
[0209] When the execution result of Task 4 is obtained for the third time, proceed to the following steps:
[0210] 1. Assuming that the execution result of task 4 is a pass result, first cache the pass result of task 4 in the second cache, the second cache = {(0, pass), (1, pass), (2, pass), (3, pass), (4, pass)}.
[0211] 2. Determine whether there is a value in the first cache. Since there is no value in the first cache, it can be determined whether the current task 4 is the last task. Since task 4 is the last task, the pass result can be output.
[0212] It can be understood that, in the above example, the last task refers to the last task among multiple tasks that outputs an execution result.
[0213] Fig.10 It is a block diagram of a data processing device according to an exemplary embodiment. The data processing device 1000 includes: an execution module 1010 , a comparison module 1020 and a judgment module 1030 .
[0214] The execution module 1010 is configured to execute multiple tasks in the thread pool to obtain an execution result of a first task, each task corresponds to a priority, and the first task is a task that has been completed among the multiple tasks;
[0215] A comparison module 1020, configured to compare the priority of the task in the first cache with the priority of the first task when the execution result is a first result, the first result being used to block the execution of the task;
[0216] The judgment module 1030 is configured to output the first result if the priority of the first task is higher than the priority of the task in the first cache, the priority of the first task is not the highest priority, and the execution result of the second task exists in the second cache; the second task is a task that has been completed among the multiple tasks, and the priority of the second task is higher than the priority of the first task.
[0217] Optionally, the data processing device 1000 further includes:
[0218] The first updating module is configured to update the first result into the first cache if the execution result of the second task does not exist in the second cache.
[0219] Optionally, the priority of each task corresponds to an identifier, and the comparison module 1020 is further configured to compare the identifier of the priority of the task in the first cache with the identifier of the priority of the first task.
[0220] Optionally, the data processing device 1000 further includes:
[0221] A second result module is configured to determine whether the first result exists in the second cache when the execution result is a second result, and the second result is used for not blocking the execution of the task;
[0222] a third task module, configured to determine whether there is an execution result of a third task in the second cache if the first result exists in the second cache, the priority of the third task being higher than the priority of the task of the first result;
[0223] a first result output module, configured to output the first result if the execution result of the third task exists in the second cache;
[0224] The second updating module is configured to update the first result into the first cache if the execution result of the third task does not exist in the second cache.
[0225] Optionally, the data processing device 1000 further includes:
[0226] The monitoring module is configured to determine whether the first task is the last task if the first result does not exist in the second cache, and output the second result if the first task is the last task.
[0227] Optionally, the data processing device 1000 further includes:
[0228] The first storage module is configured to store the second result in the second cache when the execution result is the second result, and the second result is used for not blocking the execution of the task.
[0229] Optionally, the data processing device 1000 further includes:
[0230] A priority function module, configured to determine whether to start a comparison of the priority identification of the task;
[0231] an enabling module, configured to compare the identification of the priority of the task in the first cache with the identification of the priority of the first task if the comparison of the identification of the priority of the task is enabled;
[0232] The closing module is configured to output the first result if the comparison of the identification of the priority of the task is not enabled.
[0233] Optionally, the data processing device 1000 further includes:
[0234] The second storage module is configured to store the first result in the second cache if the priority of the first task is lower than the priority of the tasks in the first cache.
[0235] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0236] Fig.11 FIG. 1 is a block diagram of a computer device 1100 according to an exemplary embodiment. Fig.11 As shown, the computer device 1100 may include: a processor 1101 and a memory 1102. The computer device 1100 may also include one or more of a multimedia component 1103, an input / output (I / O) interface 1104, and a communication component 1105.
[0237] The processor 1101 is used to control the overall operation of the computer device 1100 to complete all or part of the steps in the above-mentioned data processing method. The memory 1102 is used to store various types of data to support the operation of the computer device 1100, and these data may include, for example, instructions for any application or method used to operate on the computer device 1100, and application-related data, such as contact data, sent and received messages, pictures, audio, video, etc. The memory 1102 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (Static Random Access Memory, referred to as SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, referred to as EEPROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, referred to as EPROM), programmable read-only memory (Programmable Read-Only Memory, referred to as PROM), read-only memory (Read-Only Memory, referred to as ROM), magnetic memory, flash memory, magnetic disk or optical disk. The multimedia component 1103 may include a screen and an audio component. The screen may be, for example, a touch screen, and the audio component is used to output and / or input audio signals. For example, the audio component may include a microphone, which is used to receive external audio signals. The received audio signal may be further stored in the memory 1102 or sent through the communication component 1105. The audio component also includes at least one speaker for outputting audio signals. The I / O interface 1104 provides an interface between the processor 1101 and other interface modules, and the above-mentioned other interface modules may be keyboards, mice, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component 1105 is used for wired or wireless communication between the computer device 1100 and other devices. Wireless communication, such as Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G or 4G, or a combination of one or more of them, so the corresponding communication component 1105 may include: Wi-Fi module, Bluetooth module, NFC module.
[0238] In an exemplary embodiment, the computer device 1100 can be implemented by one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), controllers, microcontrollers, microprocessors or other electronic components to execute the above-mentioned data processing method.
[0239] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, and when the program instructions are executed by a processor, the steps of the above-mentioned data processing method are implemented. For example, the computer-readable storage medium can be the above-mentioned memory 1102 including program instructions, and the above-mentioned program instructions can be executed by the processor 1101 of the computer device 1100 to complete the above-mentioned data processing method.
[0240] Fig.12 1 is a block diagram of a computer device 1200 according to an exemplary embodiment. For example, the computer device 1200 may be provided as a server. Fig.12 The computer device 1200 includes a processor 1222, which may be one or more, and a memory 1232 for storing a computer program executable by the processor 1222. The computer program stored in the memory 1232 may include one or more modules, each corresponding to a set of instructions. In addition, the processor 1222 may be configured to execute the computer program to perform the above-mentioned data processing method.
[0241] In addition, the computer device 1200 may further include a power supply component 1226 and a communication component 1250, wherein the power supply component 1226 may be configured to perform power management of the computer device 1200, and the communication component 1250 may be configured to implement communication, for example, wired or wireless communication, of the computer device 1200. In addition, the computer device 1200 may further include an input / output (I / O) interface 1258. The computer device 1200 may operate based on an operating system stored in the memory 1232.
[0242] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, and when the program instructions are executed by a processor, the steps of the above-mentioned data processing method are implemented. For example, the computer-readable storage medium can be the above-mentioned memory 1232 including program instructions, and the above-mentioned program instructions can be executed by the processor 1222 of the computer device 1200 to complete the above-mentioned data processing method.
[0243] The preferred embodiments of the present disclosure are described in detail above in conjunction with the accompanying drawings; however, the present disclosure is not limited to the specific details in the above embodiments. Within the technical concept of the present disclosure, a variety of simple modifications can be made to the technical solution of the present disclosure, and these simple modifications all fall within the protection scope of the present disclosure.
[0244] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present disclosure will not further describe various possible combinations.
[0245] In addition, various embodiments of the present disclosure may be arbitrarily combined, and as long as they do not violate the concept of the present disclosure, they should also be regarded as the contents disclosed by the present disclosure.< / taskres> < / concurrencytask> < / concurrencytask>
Claims
1. A data processing method, characterized in that: include: Execute multiple tasks in the thread pool to obtain an execution result of a first task, each task corresponds to a priority, and the first task is a task that has been completed among the multiple tasks; When the execution result is a first result, comparing the priority of the task in the first cache with the priority of the first task, the first result being used to block the execution of the task; If the priority of the first task is higher than the priority of the tasks in the first cache, the priority of the first task is not the highest priority, and the execution result of the second task exists in the second cache, outputting the first result; The second task is a task that has been completed among the multiple tasks, and a priority of the second task is higher than a priority of the first task.
2. The method according to claim 1, characterized in that: The method further comprises: If the execution result of the second task does not exist in the second cache, the first result is updated to the first cache.
3. The method according to claim 1, characterized in that The priority of each task corresponds to an identifier, and comparing the priority of the task in the first cache with the priority of the first task includes: The identifier of the priority of the task in the first cache is compared with the identifier of the priority of the first task.
4. The method according to claim 1, characterized in that The method further comprises: When the execution result is a second result, determining whether the first result exists in the second cache, the second result being used for not blocking the execution of the task; If the first result exists in the second cache, determining whether there is an execution result of a third task in the second cache, the priority of the third task being higher than the priority of the task of the first result; If the execution result of the third task exists in the second cache, outputting the first result; If the execution result of the third task does not exist in the second cache, the first result is updated to the first cache.
5. The method according to claim 4, characterized in that The method further comprises: If the first result does not exist in the second cache, it is determined whether the first task is the last task; if the first task is the last task, the second result is output.
6. The method according to claim 1, characterized in that The method further comprises: In the case where the execution result is the second result, the second result is stored in the second cache, and the second result is used for not blocking the execution of the task.
7. The method according to claim 3, characterized in that Before comparing the identifier of the priority of the task in the first cache with the identifier of the priority of the first task, the method further includes: Comparison of flags to determine whether to enable the task priority; If the comparison of the priority flags of the tasks is enabled, the priority flags of the tasks in the first cache are compared with the priority flags of the first tasks; If the comparison of the flags of the task priorities is not enabled, the first result is output.
8. The method according to claim 1, characterized in that Before comparing the priority of the task in the first cache with the priority of the first task, the method further includes: If the priority of the first task is the highest priority, the first result is output.
9. The method according to claim 1, characterized in that: The method further comprises: If the priority of the first task is lower than the priority of the tasks in the first cache, the first result is stored in the second cache.
10. A data processing device, characterized in that: include: An execution module is configured to execute multiple tasks in the thread pool to obtain an execution result of a first task, each task corresponds to a priority, and the first task is a task that has been completed among the multiple tasks; a comparison module configured to compare the priority of the task in the first cache with the priority of the first task when the execution result is a first result, the first result being used to block the execution of the task; a determination module configured to output the first result if the priority of the first task is higher than the priority of the tasks in the first cache, the priority of the first task is not the highest priority, and the execution result of the second task exists in the second cache; The second task is a task that has been completed among the multiple tasks, and a priority of the second task is higher than a priority of the first task.
11. A computer device, characterized in that: The computer device comprises a processor and a memory, wherein the processor is configured to execute a computer program stored in the memory to implement the data processing method according to any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one instruction, and when the at least one instruction is executed by a processor, the data processing method according to any one of claims 1 to 9 is implemented.
13. A computer program product, characterized in that The computer program product stores instructions, and when the computer program product is executed, the computer implements the data processing method according to any one of claims 1 to 9.