Task processing method and related equipment

By comparing the task information and the lock list in the thread pool, duplicate tasks are accurately filtered, which solves the problem of inaccurate task filtering in the existing technology and improves the accuracy of task processing and resource utilization.

CN118819855APending Publication Date: 2024-10-22BEIJING QIYI CENTURY SCI & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410964759.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-18
Publication Date
2024-10-22

AI Technical Summary

Technical Problem

The existing task filtering method cannot accurately filter repetitive tasks, resulting in non-repetitive tasks being filtered, affecting business processing.

Method used

By obtaining the task information list and task lock list of the thread pool, compare the received task information with the task information in the thread pool, determine whether the task exists and is waiting for processing, filter if it is repeated, otherwise assign the task lock and send it to the thread pool .

Benefits of technology

It improves the accuracy of task filtering, avoids non-duplicate tasks from being filtered, saves resources, and ensures the integrity of business processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118819855A_ABST
    Figure CN118819855A_ABST
Patent Text Reader

Abstract

The invention discloses a task processing method and related equipment, and belongs to the technical field of computers. The method comprises the steps that under the condition that a first task and task information corresponding to the first task are received, a task information list and a task lock list of a thread pool are obtained, the task information list comprises task information of multiple second tasks located in the thread pool, and the task lock list comprises task information of multiple second tasks located in the thread pool; the task lock list comprises task locks corresponding to at least part of the second tasks; based on task information, a task information list and a task lock list corresponding to the first task, first target processing is carried out on the first task, and the first target processing comprises the steps that the first task is filtered; or, endowing the first task with a task lock corresponding to the first task, and sending the first task to the thread pool. According to the method, task filtering is carried out based on the task information list and the task lock list, and the accuracy of task filtering can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of computer technology, and specifically relates to a task processing method and related equipment. Background Art

[0002] In some task processing scenarios, high-frequency, repetitive tasks often occur. Some repetitive tasks do not need to be executed every time, so the repetitive tasks need to be filtered.

[0003] In the related art, some common middleware is used, such as Nginx, to set specific rules for task filtering. However, Nginx can only set simple filtering rules, such as processing only N tasks per second, and redundant tasks will be filtered, which will result in non-repetitive tasks that need to be processed being filtered. Therefore, the existing task filtering method has the problem of being unable to accurately filter repeated tasks. Summary of the invention

[0004] The purpose of the embodiments of the present application is to provide a task processing method and related devices, which can solve the problem that the existing task filtering method cannot accurately filter duplicate tasks.

[0005] In a first aspect, an embodiment of the present application provides a task processing method, the method comprising:

[0006] In the case of receiving the first task and the task information corresponding to the first task, obtaining a task information list and a task lock list of the thread pool, wherein the task information list includes the task information of multiple second tasks in the thread pool, and the task lock list includes task locks corresponding to at least some of the second tasks, wherein the at least some of the second tasks are tasks waiting to be processed among the multiple second tasks, and the task locks included in the task lock list are different;

[0007] Based on the task information corresponding to the first task, the task information list and the task lock list, a first target processing is performed on the first task, wherein the first target processing includes:

[0008] If there is a task in the thread pool that is the same as the first task and is waiting to be processed, filtering the first task;

[0009] or,

[0010] When there is no task identical to the first task and waiting to be processed in the thread pool, a corresponding task lock is allocated to the first task, and the first task is sent to the thread pool.

[0011] In a second aspect, an embodiment of the present application provides a task processing device, which is applied to a distributed lock, and the device includes:

[0012] A first acquisition module is used to acquire a task information list and a task lock list of a thread pool when receiving a first task and task information corresponding to the first task, wherein the task information list includes task information of multiple second tasks located in the thread pool, and the task lock list includes task locks corresponding to at least some of the second tasks, wherein the at least some of the second tasks are tasks waiting to be processed among the multiple second tasks, and the task locks included in the task lock list are different;

[0013] A first processing module is configured to perform a first target processing on the first task based on the task information corresponding to the first task, the task information list, and the task lock list, wherein the first target processing includes:

[0014] If there is a task in the thread pool that is the same as the first task and is waiting to be processed, filtering the first task;

[0015] or,

[0016] When there is no task identical to the first task and waiting to be processed in the thread pool, a corresponding task lock is allocated to the first task, and the first task is sent to the thread pool.

[0017] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the programs or instructions are executed by the processor, the steps of the method described in the first aspect are implemented.

[0018] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.

[0019] In an embodiment of the present application, the task information of the received first task is compared with the information contained in the task information list and the task lock list to determine whether there is a task identical to the first task in the second task, and to determine whether the task identical to the first task is a task waiting to be processed or a task being processed, and different first target processing is performed on the first task based on the judgment result. If there is a task identical to the first task in the thread pool and the task has not been processed, the first task is a duplicate task. At this time, the first task is filtered, and a task lock will not be assigned to the first task, and the first task will not be sent to the thread pool for processing. Compared with the method of filtering tasks by setting the number of tasks that can be processed per second in the prior art, the method of the embodiment of the present application can improve the accuracy of task filtering. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 One of the flowcharts of the task processing method provided in the embodiment of the present application;

[0021] Figure 2 A task processing flow diagram of a task processing component provided in an embodiment of the present application;

[0022] Figure 3 The second flowchart of the task processing method provided in the embodiment of the present application;

[0023] Figure 4 The third structural diagram of the task processing method provided in the embodiment of the present application;

[0024] Figure 5 A schematic diagram of the structure of a task processing device provided in an embodiment of the present application;

[0025] Figure 6 A schematic diagram of the structure of another task processing device provided in an embodiment of the present application;

[0026] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0027] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.

[0028] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.

[0029] The task processing method provided in the embodiment of the present application is described in detail below through specific embodiments and their application scenarios in conjunction with the accompanying drawings.

[0030] Figure 1 A flowchart of a task processing method provided in an embodiment of the present application specifically includes the following steps:

[0031] Step 101, upon receiving a first task and task information corresponding to the first task, obtain a task information list and a task lock list of the thread pool, wherein the task information list includes task information of multiple second tasks located in the thread pool, and the task lock list includes task locks corresponding to at least some of the second tasks, wherein at least some of the second tasks are tasks waiting to be processed among the multiple second tasks, and the task locks included in the task lock list are different.

[0032] like Figure 2 The figure shows a task processing component, including a distributed lock and a thread pool, wherein the distributed lock can be implemented based on a database, a cache (such as Redis), or Zookeeper. The distributed lock is used to assign a task lock corresponding to a task based on the task information of a task, and send the task to the thread pool, which is used to execute the task. Among them, the task lock is determined by the task information, and the task locks in the task lock list are different, that is, only one of the same task locks can exist at the same time in the task lock list. For example, if task 1 and task 2 are the same task, then the task locks assigned by the distributed lock to task 1 and task 2 will also be the same, but since only one of the same task locks can exist at the same time, when the task lock of task 1 exists, the distributed lock will not be able to assign a task lock to task 2.

[0033] Figure 1 The task processing method shown in the embodiment can be applied to Figure 2 The task processing components shown.

[0034] Please see further Figure 2 , the task information includes two parameters, namely the classification parameter and the task ID parameter. If the task information of two tasks is consistent, that is, the classification parameters and task ID parameters of the two tasks are consistent, it means that the two tasks belong to the same task. Figure 2 Task 1 and Task 2 shown belong to the same task, and Task 3 and Task 4 belong to the same task.

[0035] The task information list includes task information corresponding to the second task. The second task refers to a task in the thread pool. The thread pool includes execution threads and queue threads. That is, tasks in the execution threads and queue threads are second tasks. Tasks in the execution threads are tasks being processed, and tasks in the queue threads are tasks waiting to be processed. Figure 2As shown, the distributed lock uses a synchronous processing method. When task 3 is sent to the distributed lock, task 3 belongs to the first task, and tasks 1 and 2 are in the thread pool. At this time, tasks 1 and 2 belong to the second task. When task 4 is sent to the task processing system, task 4 belongs to the first task, and tasks 1, 2, and 3 are all in the thread pool. Tasks 1, 2, and 3 all belong to the second task. Similarly, the task lock list includes the task lock corresponding to the second task. It should be noted that some tasks in the second task may not have corresponding task locks. For example, when the task processing rule of the thread pool is to unlock the task lock before processing the task, Figure 2 Task 1 in enters the task processing component. After the corresponding task lock is assigned to task 1, task 1 enters the thread pool. The thread pool first unlocks the task lock of task 1 and then processes task 1. During the processing of task 1, task 1 is still in the thread pool, but does not have the task lock; therefore, although task 2 has the same task information as task 1, since the task lock of task 1 has been unlocked, the corresponding task lock can be assigned to task 2.

[0036] Step 102, based on the task information corresponding to the first task, the task information list and the task lock list, perform first target processing on the first task, wherein the first target processing includes: when there is a task identical to the first task in the thread pool, filtering the first task; or, when there is no task identical to the first task in the thread pool, assigning a corresponding task lock to the first task and sending the first task to the thread pool.

[0037] Compare the task information corresponding to the first task with the information contained in the task information list and the task lock list, determine whether there is a task identical to the first task in the second task, and determine whether the task identical to the first task is a task waiting to be processed or a task being processed, and perform different first target processing on the first task based on the determination result. Figure 2 Task 1, Task 2, and Task 3 shown in the figure all belong to the situation of "assigning a task lock corresponding to the first task and sending the first task to the thread pool". Figure 2 Task 4 is directly filtered, the thread pool will not execute Task 4 which is repeated with Task 3, and the thread pool will not receive any request for Task 4, which belongs to the situation of "filtering the first task".

[0038] In the task processing method of the embodiment of the present application, the task information of the received first task is compared with the information contained in the task information list and the task lock list, and it is judged whether there is a task identical to the first task in the second task, and it is judged whether the task identical to the first task belongs to a task waiting to be processed or a task being processed, and different first target processing is performed on the first task based on the judgment result. In the case where there is a task identical to the first task in the thread pool, and the task is not processed, the first task is a repeated task. At this time, filtering the first task will not assign a task lock to the first task, and the first task will not be sent to the thread pool for processing. Compared with the method of filtering tasks by setting the number of tasks that can be processed per second in the prior art, the method of the embodiment of the present application can improve the accuracy of task filtering. In addition, since the task processing method of the embodiment of the present application filters only repeated tasks, therefore, task filtering will not cause some tasks that need to be processed to be not processed, that is, using the method of the embodiment of the present application will not have any impact and perception on the actual business.

[0039] In an alternative embodiment, Figure 2 The task processing component shown is deployed in the server serving as the task initiator. Based on the task processing method of the embodiment of the present application, the filtered tasks will not be sent to the thread pool, and the thread pool will not issue a task processing request to the server serving as the task processing end. Therefore, the resources required to issue a task processing request can be saved.

[0040] Optionally, in step 102, the performing target processing on the first task based on the task information corresponding to the first task, the task information list and the task lock list includes:

[0041] If there is target task information consistent with the task information corresponding to the first task in the task information list, and there is a task lock corresponding to the target task in the task lock list, filtering the first task;

[0042] When there is no target task information consistent with the task information corresponding to the first task in the task information list, or when there is no task lock corresponding to the target task in the task lock list, the corresponding task lock is assigned to the first task and the first task is sent to the thread pool.

[0043] See also Figure 2 When Task 1 is sent to the distributed lock as the first task, there is no target task information consistent with the task information of the first task in the task information list, and a task lock is assigned to Task 1 and sent to the thread pool.

[0044] When Task 2 is sent to the distributed lock as the first task, Task 1 exists in the thread pool, and the task information of Task 1 is the same as that of Task 2. However, since the thread pool can unlock Task 1 first when executing Task 1, there is no task lock corresponding to Task 1 in the task lock list. Therefore, a task lock can be assigned to Task 2 and Task 2 can be sent to the thread pool.

[0045] When Task 3 is sent to the distributed lock as the first task, there is no task information identical to Task 3 in the thread pool, so a task lock is assigned to Task 3 and it is sent to the thread pool. Since the thread pool does not have idle resources, Task 3 is queued in the queue thread.

[0046] When Task 4 is sent to the distributed lock as the first task, there is Task 3 in the thread pool. The task information of Task 3 is the same as that of Task 4. Since Task 3 is in the queue and the task lock is not unlocked, the task lock corresponding to Task 3 exists in the task lock list. The task lock cannot be assigned to Task 4. Task 4 is directly filtered and will not be sent to the thread pool, saving resources.

[0047] In this embodiment, how to process the first task is determined by determining whether there is target task information consistent with the task information corresponding to the first task in the task information list and whether there is a task lock corresponding to the target task in the task lock list. This ensures the normal processing of the task and can filter out duplicate tasks while saving resources.

[0048] The thread pool includes execution threads and queuing threads. After the first task is processed by the first target, Figure 3 As shown, the method also includes:

[0049] Step 103: When the first target processing is to assign a corresponding task lock to the first task and send the first task to the thread pool, obtain the running information of the thread pool.

[0050] The running information of the thread pool may include the number of idle threads in the execution thread, the number of tasks in the execution thread, the number of tasks in the queue thread, etc.

[0051] Step 104: Based on the running information of the thread pool, perform a second target processing on the first task, wherein the second target processing includes any one of the following:

[0052] After unlocking the first task lock by using the execution thread, the first task is executed, where the first task lock is the task lock corresponding to the first task;

[0053] After completing the first task using the execution thread, unlocking the first task lock;

[0054] Add the first task to the queue thread.

[0055] The built-in parameters of the thread pool include unLockFirst, which is used to decide whether to unlock first and then execute the task, or to unlock after completing the task. Figure 2 and Figure 4 As shown in the figure, when task 1 enters the execution thread, the task lock of task 1 is unlocked first, and then task 1 is executed. Then, when task 2 enters the distributed lock, there is no task lock corresponding to task 2 in the thread pool. Therefore, a task lock can be assigned to task 2 and sent to the thread pool for further execution. If the task is completed first and then unlocked, when task 1 enters the execution thread, task 1 is executed first. During the execution of task 1, the task lock corresponding to task 1 exists. Then, when task 2 enters the distributed lock, since task 2 and task 1 have the same task information, and only one task lock can exist at the same time, a task lock cannot be assigned to task 2, and task 2 is directly filtered. By comparison, it can be seen that more tasks can be executed by unlocking first, and more duplicate tasks can be filtered by unlocking later.

[0056] In this embodiment, the operation status of the thread pool is judged according to the operation information of the thread pool. When the thread pool has idle resources, the received task is executed. When the thread pool does not have idle resources, the task is added to the queue thread to prevent the thread pool from being overly stressed in executing tasks, thereby ensuring the stable operation of the thread pool.

[0057] Optionally, step 104, performing second target processing on the first task based on the running information of the thread pool, includes:

[0058] When the running information of the thread pool indicates that all the execution threads of the thread pool are executing tasks, adding the first task to the queue thread for queuing;

[0059] When the running information of the thread pool indicates that there is a target execution thread among the execution threads of the thread pool that has not executed a task, the first task is executed after the first task lock is unlocked by the target execution thread; or the first task lock is unlocked after the first task is completed by the target execution thread.

[0060] According to the running information of the execution threads in the thread pool, the specific method of processing the second target can be determined. In addition to the case where all the execution threads in the thread pool are executing tasks, the CPU and memory resources of the thread pool are insufficient, the Java Virtual Machine (JVM) is garbage collecting, etc., it is also necessary to add the first task to the queue thread.

[0061] In this embodiment, how to process the first task is determined by judging the running information of the thread pool, thereby ensuring the stable running of the thread pool.

[0062] Optionally, when the lock duration of the first task lock exceeds a preset duration, the first task lock is unlocked. The built-in parameters of the thread pool also include lockTime, i.e., a preset duration. When the lock duration of the first task lock corresponding to the first task exceeds the preset duration, for example, more than 20s, the first task lock will be automatically unlocked, so that the thread pool can still operate normally in the case of "the service crashes before unlocking, resulting in failure to unlock normally; unLockFirst is set to unlock later, but the execution of the task is abnormal, resulting in abnormal time consumption and failure to unlock in time", instead of filtering all tasks.

[0063] also, Figure 2 The task processing component shown also includes a fallback built-in parameter, which is configured to directly send the task to the thread pool for task processing when the distributed lock in the task processing component is unavailable (for example, the response times out). In the case of "the distributed lock times out due to service downtime or network problems resulting in no timely response", the method of the embodiment of the present application is not executed, the process of the distributed lock assigning the task lock to the task is skipped, and the task is directly sent to the thread pool for processing, thereby ensuring the stable operation of the task processing component.

[0064] It should be noted that the task processing component of the embodiment of the present application is relative to the Nginx of the prior art. Nginx is configured to filter only the network requests received about task processing in the server of the task processing end, and the task processing component processes the task information of the task during the task processing method of the embodiment of the present application. The parameters included in the task information are classification parameters and task ID parameters. The classification parameters are used to indicate the form of expression of the task information, such as code, Event, and network request. The task ID parameter is used to indicate the specific content of the task. Therefore, in the method of the embodiment of the present application, whether the first task received is a piece of code, Event, or network request, it can be processed by the task information of the first task. Whether it is a distributed lock or a thread pool, it can be directly referenced in the server without additional configuration, and has the characteristics of lightweight. In addition, multiple parameters such as lockTime and unLockFirst are set in the task processing component, and the parameters can be adjusted according to the actual business situation, which is flexible and suitable for various scenarios and has the characteristics of scalability.

[0065] like Figure 5 As shown, the embodiment of the present application further provides a task processing device 500, and the task processing device 500 includes:

[0066] A first acquisition module 501 is used to acquire a task information list and a task lock list of a thread pool when receiving a first task and task information corresponding to the first task, wherein the task information list includes task information of multiple second tasks in the thread pool, and the task lock list includes task locks corresponding to at least some of the second tasks, wherein at least some of the second tasks are tasks waiting to be processed among the multiple second tasks, and the task locks included in the task lock list are different;

[0067] The first processing module 502 is configured to perform a first target processing on the first task based on the task information corresponding to the first task, the task information list and the task lock list, wherein the first target processing includes:

[0068] If there is a task in the thread pool that is the same as the first task and is waiting to be processed, filtering the first task;

[0069] or,

[0070] When there is no task identical to the first task and waiting to be processed in the thread pool, a corresponding task lock is allocated to the first task, and the first task is sent to the thread pool.

[0071] Optionally, the first processing module 502 is further configured to:

[0072] If there is target task information consistent with the task information corresponding to the first task in the task information list, and there is a task lock corresponding to the target task in the task lock list, filtering the first task;

[0073] When there is no target task information consistent with the task information corresponding to the first task in the task information list, or when there is no task lock corresponding to the target task in the task lock list, the corresponding task lock is assigned to the first task and the first task is sent to the thread pool.

[0074] It should be noted that the task processing device 500 provided in the embodiment of the present application can implement the following Figure 1 The entire technical process of the task processing method shown in the embodiment achieves the same technical effect and will not be described again here to avoid repetition.

[0075] like Figure 6 As shown, the embodiment of the present application further provides a task processing device 500, and the task processing device 500 includes:

[0076] A first acquisition module 501 is used to acquire a task information list and a task lock list of a thread pool when receiving a first task and task information corresponding to the first task, wherein the task information list includes task information of multiple second tasks in the thread pool, and the task lock list includes task locks corresponding to at least some of the second tasks, wherein the at least some of the second tasks are tasks waiting to be processed among the multiple second tasks, and the task locks are used to mark the corresponding second tasks;

[0077] The first processing module 502 is configured to perform a first target processing on the first task based on the task information corresponding to the first task, the task information list and the task lock list, wherein the first target processing includes:

[0078] If there is a task in the thread pool that is the same as the first task and is waiting to be processed, filtering the first task;

[0079] or,

[0080] When there is no task identical to the first task and waiting to be processed in the thread pool, assign a corresponding task lock to the first task and send the first task to the thread pool;

[0081] A second acquisition module 503 is used to acquire the running information of the thread pool when the first target processing is to assign a corresponding task lock to the first task and send the first task to the thread pool;

[0082] The second processing module 504 is used to perform a second target processing on the first task based on the running information of the thread pool, wherein the second target processing includes any one of the following:

[0083] After unlocking the first task lock by using the execution thread, the first task is executed, where the first task lock is the task lock corresponding to the first task;

[0084] After completing the first task using the execution thread, unlocking the first task lock;

[0085] Add the first task to the queue thread.

[0086] Optionally, the second processing module 504 is further configured to:

[0087] When the running information of the thread pool indicates that all the execution threads of the thread pool are executing tasks, adding the first task to the queue thread for queuing;

[0088] When the running information of the thread pool indicates that there is a target execution thread among the execution threads of the thread pool that has not executed a task, the first task is executed after the first task lock is unlocked by the target execution thread; or the first task lock is unlocked after the first task is completed by the target execution thread.

[0089] Optionally, when the locking time of the first task lock exceeds a preset time, the first task lock is unlocked.

[0090] It should be noted that the task processing device 500 provided in the embodiment of the present application can implement the following Figure 3 The entire technical process of the task processing method shown in the embodiment achieves the same technical effect and will not be described again here to avoid repetition.

[0091] The task processing device in the embodiment of the present application can be an electronic device, or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or other devices other than a terminal. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmented reality, AR) / virtual reality (virtual reality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and the non-mobile electronic device can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.

[0092] Alternatively, if Figure 7 As shown, the embodiment of the present application also provides an electronic device 700, including a processor 701 and a memory 702, the memory 702 stores a program or instruction that can be run on the processor 701, and the program or instruction is executed by the processor 701 to implement Figure 1 or Figure 3 The various steps of the method embodiment shown can achieve the same technical effect, and will not be described again here to avoid repetition.

[0093] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.

[0094] The embodiment of the present application also provides a readable storage medium on which a program or instruction is stored. When the program or instruction is executed by a processor, Figure 1 or Figure 3 The various processes of the method embodiment shown can achieve the same technical effect, and will not be described again here to avoid repetition.

[0095] The processor is a processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0096] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0097] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0098] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A task processing method, characterized in that: The method comprises: In the case of receiving the first task and the task information corresponding to the first task, obtaining a task information list and a task lock list of the thread pool, wherein the task information list includes the task information of multiple second tasks in the thread pool, and the task lock list includes task locks corresponding to at least some of the second tasks, wherein the at least some of the second tasks are tasks waiting to be processed among the multiple second tasks, and the task locks included in the task lock list are different; Based on the task information corresponding to the first task, the task information list and the task lock list, a first target processing is performed on the first task, wherein the first target processing includes: If there is a task in the thread pool that is the same as the first task and is waiting to be processed, filtering the first task; or, When there is no task identical to the first task and waiting to be processed in the thread pool, a corresponding task lock is allocated to the first task, and the first task is sent to the thread pool.

2. The method according to claim 1, characterized in that The performing first target processing on the first task based on the task information corresponding to the first task, the task information list and the task lock list includes: If there is target task information consistent with the task information corresponding to the first task in the task information list, and there is a task lock corresponding to the target task in the task lock list, filtering the first task; When there is no target task information consistent with the task information corresponding to the first task in the task information list, or when there is no task lock corresponding to the target task in the task lock list, the corresponding task lock is assigned to the first task and the first task is sent to the thread pool.

3. The method according to any one of claims 1 to 2, characterized in that The thread pool includes execution threads and queuing threads. After performing the first target processing on the first task, the method further includes: When the first target processing is to assign a corresponding task lock to the first task and send the first task to the thread pool, obtaining the running information of the thread pool; Based on the running information of the thread pool, a second target processing is performed on the first task, wherein the second target processing includes any one of the following: After unlocking the first task lock by using the execution thread, the first task is executed, where the first task lock is the task lock corresponding to the first task; After completing the first task using the execution thread, unlocking the first task lock; Add the first task to the queue thread.

4. The method according to claim 3, characterized in that The performing second target processing on the first task based on the running information of the thread pool includes: When the running information of the thread pool indicates that all the execution threads of the thread pool are executing tasks, adding the first task to the queue thread for queuing; When the running information of the thread pool indicates that there is a target execution thread among the execution threads of the thread pool that has not executed a task, the first task is executed after the first task lock is unlocked by the target execution thread; or the first task lock is unlocked after the first task is completed by the target execution thread.

5. The method according to claim 3, characterized in that When the locking time of the first task lock exceeds a preset time, the first task lock is unlocked.

6. A task processing device, characterized in that: The task processing device comprises: A first acquisition module is used to acquire a task information list and a task lock list of a thread pool when receiving a first task and task information corresponding to the first task, wherein the task information list includes task information of multiple second tasks located in the thread pool, and the task lock list includes task locks corresponding to at least some of the second tasks, wherein the at least some of the second tasks are tasks waiting to be processed among the multiple second tasks, and the task locks included in the task lock list are different; A first processing module is configured to perform a first target processing on the first task based on the task information corresponding to the first task, the task information list, and the task lock list, wherein the first target processing includes: If there is a task in the thread pool that is the same as the first task and is waiting to be processed, filtering the first task; or, When there is no task identical to the first task and waiting to be processed in the thread pool, a corresponding task lock is allocated to the first task, and the first task is sent to the thread pool.

7. The task processing device according to claim 6, characterized in that: The thread pool includes execution threads and queuing threads, and the task processing device includes: A second acquisition module is used to acquire the running information of the thread pool when the first target processing is to assign a corresponding task lock to the first task and send the first task to the thread pool; A second processing module is configured to perform a second target processing on the first task based on the running information of the thread pool, wherein the second target processing includes any one of the following: After unlocking the first task lock by using the execution thread, the first task is executed, where the first task lock is the task lock corresponding to the first task; After completing the first task using the execution thread, unlocking the first task lock; Add the first task to the queue thread.

8. The task processing device according to claim 7, characterized in that: When the locking time of the first task lock exceeds a preset time, the first task lock is unlocked.

9. An electronic device, characterized in that: The electronic device includes a processor and a memory, wherein the memory stores a program or instruction that can be run on the processor, and when the program or instruction is executed by the processor, the steps of the task processing method according to any one of claims 1 to 5 are implemented.

10. A readable storage medium, characterized in that: The readable storage medium stores a program or an instruction, and when the program or the instruction is executed by the processor, the steps of the task processing method according to any one of claims 1 to 5 are implemented.