Task processing method and apparatus, device, and storage medium

By mounting tasks to multiple lifecycle nodes and scheduling child thread execution when the lifecycle node enters an event, the problem of excessive time-consuming tasks caused by serial execution of the main thread is solved, improving the user experience.

WO2024240193A1PCT designated stage expired Publication Date: 2024-11-28BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/094758
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-05-23
Filing Date
2024-05-22
Publication Date
2024-11-28

AI Technical Summary

Technical Problem

In business scenarios, the main thread performs tasks serially, which causes tasks to take a long time to execute, affecting the user experience.

Method used

By mounting tasks on multiple lifecycle nodes of the target scenario and scheduling child threads to execute tasks asynchronously when the lifecycle node enters an event, the task execution time is reduced.

Benefits of technology

It effectively reduces the time-consuming task execution in business scenarios and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024094758_28112024_PF_FP_ABST
    Figure CN2024094758_28112024_PF_FP_ABST
Patent Text Reader

Abstract

The present disclosure provides a task processing method and apparatus, a device, and a storage medium. The method comprises: upon receipt of a preset entry event for a first life cycle node, determining a task mounted on the first life cycle node as a task to be executed, wherein the first life cycle node belongs to a plurality of life cycle nodes obtained by dividing the life cycle of a target scenario, the target scenario corresponds to a plurality of tasks, and the plurality of tasks are respectively mounted on the same life cycle node or different life cycle nodes in the target scenario; and scheduling at least one child thread to execute the task to be executed.
Need to check novelty before this filing date? Find Prior Art

Description

A task processing method, device, equipment and storage medium

[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on May 23, 2023, with application number 202310588309.6 and invention name “A task processing method, device, equipment and storage medium”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The present disclosure relates to the field of data processing, and in particular to a task processing method, apparatus, device, and storage medium. Background Art

[0003] Currently, when executing multiple tasks in business scenarios, the main thread is usually used to execute tasks serially, executing each task in sequence. However, this task processing method requires a long total time to execute tasks in business scenarios, which can easily affect the user experience.

[0004] Therefore, how to reduce the time spent on task execution in business scenarios and improve user experience is a technical problem that needs to be solved urgently.

[0005] Summary of the Invention

[0006] In order to solve the above technical problems, an embodiment of the present disclosure provides a task processing method.

[0007] In a first aspect, the present disclosure provides a task processing method, the method comprising:

[0008] In response to a preset entry event for a first lifecycle node, determining a task mounted on the first lifecycle node as a task to be executed; wherein the first lifecycle node belongs to a plurality of lifecycle nodes obtained by dividing the lifecycle of a target scenario, the target scenario corresponds to a plurality of tasks, and the plurality of tasks are respectively mounted on the same or different lifecycle nodes in the target scenario;

[0009] At least one sub-thread is scheduled to execute the task to be executed.

[0010] In an optional implementation, the to-be-executed task includes a first to-be-executed task, and before scheduling at least one sub-thread to execute the to-be-executed task, the method further includes:

[0011] If it is determined that the first task to be executed has execution dependency information, determining whether a dependent execution result of the first task to be executed is currently stored based on the execution dependency information; wherein the execution dependency information carries identification information of the dependent execution result;

[0012] Accordingly, scheduling at least one sub-thread to execute the task to be executed includes:

[0013] If it is determined that the dependent execution result of the first to-be-executed task is currently stored, the first sub-thread is scheduled to execute the first to-be-executed task based on the dependent execution result.

[0014] In an optional implementation, the method further includes:

[0015] If it is determined that the dependent execution result of the first to-be-executed task is not currently stored, the main thread executes the task on which the first to-be-executed task depends to obtain the execution result of the task;

[0016] The second sub-thread is scheduled to execute the first task to be executed based on the execution result of the task.

[0017] In an optional embodiment, before determining the task mounted on the first lifecycle node as the task to be executed in response to the preset entry event of the first lifecycle node, the method further includes:

[0018] Receive a mount request for a first task corresponding to the target scenario; wherein the mount request carries an identifier of a target lifecycle node;

[0019] Mount the first task to the target lifecycle node.

[0020] In an optional implementation, there is no execution dependency between different tasks mounted on the same lifecycle node of the target scenario.

[0021] In an optional embodiment, the multiple lifecycle nodes include a second lifecycle node and a third lifecycle node, the multiple tasks include a second task and a third task that have an execution dependency relationship, the execution dependency relationship includes a relationship in which the third task depends on the execution of the second task, the second task is mounted on the second lifecycle node, and the third task is mounted on the third lifecycle node.

[0022] In an optional implementation, the method further includes:

[0023] In response to a preset exit event for the first lifecycle node, determining an execution status of a task mounted on the first lifecycle node; wherein the execution status is used to reflect whether the task has been completed;

[0024] Send the execution status of the task mounted on the first lifecycle node; wherein the execution status of the task mounted on the first lifecycle node is used to update the number of tasks mounted on the first lifecycle node and / or the at least one sub-thread.

[0025] In a second aspect, the present disclosure provides a task processing device, the device comprising:

[0026] A first determining module is configured to determine, in response to a preset entry event for a first lifecycle node, a task mounted on the first lifecycle node as a task to be executed; wherein the first lifecycle node belongs to a plurality of lifecycle nodes obtained by dividing the lifecycle of a target scenario, the target scenario corresponds to a plurality of tasks, and the plurality of tasks are respectively mounted on the same or different lifecycle nodes in the target scenario;

[0027] The first execution module is used to schedule at least one sub-thread to execute the task to be executed.

[0028] In a third aspect, the present disclosure provides a computer-readable storage medium, wherein instructions are stored in the computer-readable storage medium. When the instructions are executed on a terminal device, the terminal device implements the above method.

[0029] In a fourth aspect, the present disclosure provides a task processing device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned method when executing the computer program.

[0030] In a fifth aspect, the present disclosure provides a computer program product, which includes a computer program / instructions, and the computer program / instructions implement the above method when executed by a processor. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0032] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0033] FIG1 is a flowchart of a task processing method provided by an embodiment of the present disclosure;

[0034] FIG2 is a schematic diagram of a task processing architecture provided by an embodiment of the present disclosure;

[0035] FIG3 is a schematic diagram of the structure of a task processing device provided by an embodiment of the present disclosure;

[0036] FIG4 is a schematic structural diagram of a task processing device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0037] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features therein can be combined with each other in the absence of conflict.

[0038] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.

[0039] Currently, when executing multiple tasks in business scenarios, the main thread is usually used to execute tasks serially, executing each task in sequence. However, this task processing method takes a long time to execute and can easily affect the user experience.

[0040] Therefore, how to reduce the time spent on task execution in business scenarios and improve user experience is a technical problem that needs to be solved urgently.

[0041] In order to reduce the time consumption of task execution in business scenarios, the embodiment of the present disclosure provides a task processing method, which determines the task mounted on the first life cycle node as a task to be executed when a preset entry event for the first life cycle node is received; wherein the first life cycle node belongs to a plurality of life cycle nodes obtained by dividing the life cycle of the target scenario, the target scenario corresponds to a plurality of tasks, and the plurality of tasks are respectively mounted on the same or different life cycle nodes in the target scenario; and schedules at least one child thread to execute the task to be executed. It can be seen that the embodiment of the present disclosure pre-mounts a plurality of tasks on a plurality of life cycle nodes, and when entering a certain life cycle node, asynchronously executes the task mounted on the life cycle node by scheduling at least one child thread, thereby reducing the time consumption of task execution in the target scenario and improving the user experience.

[0042] Based on this, an embodiment of the present disclosure provides a task processing method. Referring to FIG1 , which is a flow chart of a task processing method provided by an embodiment of the present disclosure, the method specifically includes:

[0043] S101: In response to a preset entry event for a first lifecycle node, determine a task mounted on the first lifecycle node as a task to be executed.

[0044] Among them, the first life cycle node belongs to multiple life cycle nodes obtained by dividing the life cycle of the target scene, the target scene corresponds to multiple tasks, and the multiple tasks are respectively mounted on the same or different life cycle nodes in the target scene.

[0045] The task processing method provided by the embodiment of the present disclosure can be applied to a client, and specifically can be applied to an application program deployed on the client.

[0046] In actual applications, the target scenario is also called the target business scenario, which can be determined based on the actual business type. For example, in the live broadcast business type, any business scenario involved in the live broadcast business type can be determined as the target scenario according to actual needs, such as the scene of the user watching the broadcast entering the live broadcast room (entering the room scene), the scene of the host connecting with the host, etc. The embodiments of the present disclosure do not limit this.

[0047] Among them, the life cycle of the target scene refers to all the stages experienced from entering the target scene to exiting the target scene. Specifically, the different stages experienced by the target scene can be represented by dividing the life cycle of the target scene into multiple life cycle nodes.

[0048] In the embodiment of the present disclosure, the lifecycle of the target scenario may be divided into multiple lifecycle nodes, and each lifecycle node may be mounted with one or more tasks.

[0049] For example, the scenario where a user enters a live broadcast room can be divided into multiple lifecycle nodes, such as SDK (Software Development Kit) initialization completion, user entry into the live broadcast page, and user viewing a specific live broadcast room. Among them, the lifecycle node where SDK initialization is completed can be mounted with tasks such as loading a preview stream, and the lifecycle node where the user enters the live broadcast page can be mounted with tasks such as loading page components and loading images. In other words, the tasks corresponding to the target scenario can be the tasks that need to be performed from entering the target scenario (start) to exiting the target business scenario (end), and the tasks mounted at each lifecycle node can be the tasks corresponding to this lifecycle node, such as the tasks that need to be completed through this lifecycle node.

[0050] In an optional implementation, the target scene may include a scene of entering a live broadcast room. Specifically, the process of entering the live broadcast room may be from clicking the live broadcast room control to completing the display of the live broadcast room page. In this scenario, the life cycle of the target scene can be pre-divided into life cycle nodes such as SDK initialization completion, entering the live broadcast page, and watching a specific live broadcast room. As shown in Figure 2, this is an architectural diagram of task processing provided by an embodiment of the present disclosure.

[0051] In an embodiment of the present disclosure, after the life cycle of the target scene is divided into multiple life cycle nodes in advance, each life cycle node corresponds to a preset entry event and a preset exit event, wherein the preset entry event refers to an event used to trigger the opening of the first life cycle node, and the preset exit event refers to an event used to trigger the exit of the first life cycle node; when the main thread executes a certain life cycle node, it detects each event on the life cycle node, and when the preset entry event corresponding to the life cycle node is detected, the task mounted on the first life cycle node is determined as the task to be executed.

[0052] For example, in the scenario of entering a live broadcast room, when an event of entering a live broadcast room page node is detected, one or more tasks mounted on the live broadcast room page node are first determined. Assuming that the tasks mounted on the node include tasks such as loading page components and loading images, the loading page component tasks and loading image tasks are treated as tasks to be executed, so that the above-mentioned tasks to be executed can be executed later by scheduling at least one child thread.

[0053] In the embodiment of the present disclosure, the target scene corresponds to multiple tasks, and the multiple tasks are respectively mounted on the same or different life cycle nodes in the target scene. By pre-mounting the tasks on the life cycle nodes in the target scene, a correspondence between the tasks and the life cycle nodes is established, so that when a life cycle node is subsequently started, the tasks mounted on the life cycle node can be determined based on the life cycle node.

[0054] In the embodiment of the present disclosure, the first life cycle node can be any life cycle node in the target scene. For example, in the scene of entering the live broadcast room, the first life cycle node can be the node of entering the live broadcast page.

[0055] In actual applications, before determining the task mounted on the first lifecycle node, each task in the target scenario needs to be mounted on the corresponding lifecycle node.

[0056] In an optional implementation, upon receiving a mount request for a first task corresponding to a target scenario, the first task may be mounted to a target lifecycle node, wherein the mount request carries an identifier of the target lifecycle node.

[0057] In an embodiment of the present disclosure, the first task can be any one of the multiple tasks corresponding to the target scene. When a mount request for the first task is received, the first task is mounted on the target lifecycle node based on the identifier of the target lifecycle node carried in the mount request, thereby establishing a correspondence between the first task and the target lifecycle node, so that when a preset entry event of the target lifecycle node is subsequently received, the task mounted on the target lifecycle node can be determined based on the above correspondence.

[0058] In the embodiment of the present disclosure, since there is a corresponding relationship between the first life cycle node and the task mounted on the first life cycle node, when the preset entry event of the first life cycle node is received, the task mounted on the first life cycle node can be determined as the task to be executed based on the above corresponding relationship, so that the task to be executed can be executed subsequently.

[0059] S102: Scheduling at least one sub-thread to execute the task to be executed.

[0060] In an embodiment of the present disclosure, when the main thread receives a preset entry event of the first lifecycle node, it takes the task mounted on the first lifecycle node as a task to be executed, and then schedules at least one child thread to execute the task to be executed.

[0061] In actual applications, the number of child threads can be set based on demand. It is important to note that by scheduling multiple child threads, multiple tasks mounted on the same lifecycle node can be executed asynchronously. The number of child threads determines the number of tasks that can be executed asynchronously. Compared to the existing method of scheduling a main thread to execute multiple tasks serially, the embodiment of the present disclosure can schedule multiple child threads to execute multiple tasks asynchronously, thereby reducing the time required to execute tasks in the target scenario, shortening the user's waiting time, and improving the user experience.

[0062] In an optional implementation, after the task mounted on the first lifecycle node is determined as a task to be executed, the task to be executed can be encapsulated in a task queue for queueing. When an idle sub-thread appears, the task to be executed is taken out from the task queue and placed on the idle sub-thread for execution.

[0063] In an optional implementation, the target scenario may include a scenario of entering a live broadcast room. In this scenario, tasks on nodes such as initialization completion, entering the live broadcast page, and entering a specific live broadcast room are asynchronously executed by scheduling at least one sub-thread, thereby reducing the time consumption of task execution in the target scenario and improving the user experience.

[0064] In the task processing method provided by the embodiment of the present disclosure, when a preset entry event for the first life cycle node is received, the task mounted on the first life cycle node is determined as a task to be executed; wherein, the first life cycle node belongs to a plurality of life cycle nodes obtained by dividing the life cycle of the target scene, the target scene corresponds to a plurality of tasks, and the plurality of tasks are respectively mounted on the same or different life cycle nodes in the target scene; and at least one child thread is scheduled to execute the task to be executed. It can be seen that the embodiment of the present disclosure mounts a plurality of tasks on a plurality of life cycle nodes in advance, and when entering a certain life cycle node, the task mounted on the life cycle node is asynchronously executed by scheduling at least one child thread, thereby reducing the time consumption of task execution in the target scene and improving the user experience.

[0065] In actual applications, the tasks to be executed may include the first task to be executed. Before scheduling the child thread to execute the first task to be executed, it is first necessary to determine whether there is execution dependency information for the first task to be executed, wherein the execution dependency information carries identification information of the dependent execution result of the first task to be executed.

[0066] If it is determined that there is execution dependency information for the first task to be executed, it means that the execution of the first task to be executed depends on one or more execution results of a certain task, where one or more execution results of a certain task can be called dependent execution results of the first task to be executed. Therefore, before executing the first task to be executed, it is also necessary to determine whether the dependent execution results of the first task to be executed are currently stored.

[0067] Specifically, if it is determined that there is execution dependency information for the first task to be executed, then based on the identification information of the dependency execution result carried in the execution dependency information, it is determined whether the dependency execution result of the first task to be executed is currently stored. Only after the dependency execution result of the first task to be executed is obtained can the child thread be scheduled to execute the first task to be executed.

[0068] In an embodiment of the present disclosure, the execution dependency information may carry a task identifier corresponding to the task on which the first task to be executed depends. For example, if the task on which the first task to be executed depends is A, the execution dependency information of the first task to be executed may carry the task identifier of task A. The execution dependency information may also carry identification information of the dependency execution result corresponding to the dependent task. For example, if the dependency execution result of the first task to be executed is an intermediate execution result of task A, the execution dependency information of the first task to be executed may carry identification information of the intermediate execution result.

[0069] In an optional implementation, it is possible to determine whether the dependent execution result of the first task to be executed exists in the preset execution result storage module based on the identification information of the dependent execution result carried in the execution dependency information. For example, assuming that the execution dependency information carries the identification information corresponding to the intermediate execution result A1 of task A, it is possible to query whether the intermediate execution result A1 of task A exists in the preset execution result storage module based on the identification information.

[0070] In an optional implementation, if it is determined that a dependent execution result of the first to-be-executed task is currently stored, the first sub-thread is scheduled to execute the first to-be-executed task based on the dependent execution result; wherein the first sub-thread belongs to at least one sub-thread.

[0071] In another optional implementation, if it is determined that the dependent execution result of the first task to be executed is not currently stored, the main thread executes the task on which the first task to be executed depends, obtains the execution result of the task, and then schedules the second sub-thread to execute the first task to be executed based on the execution result of the task; wherein, the second sub-thread can be the same sub-thread as the first sub-thread, or can be a different sub-thread.

[0072] In actual applications, the execution results corresponding to the completed tasks can also be stored in a preset execution result storage module in advance. When it is determined that the first task to be executed has execution dependency information, the preset execution result storage module is queried whether the execution result on which the first task to be executed depends is stored. If it is determined that the execution result on which the first task to be executed depends does not exist in the preset execution result storage module, the main thread executes the task on which the first task to be executed depends to obtain the execution result of the task.

[0073] In the embodiment of the present disclosure, if the execution result on which the first task to be executed depends does not exist in the execution result storage module, it means that the task on which the first task to be executed depends is being executed by a child thread, or is still waiting for execution in the task queue. At this time, the main thread can execute the task on which the first task to be executed depends to obtain the execution result of the dependent task.

[0074] In an optional implementation, after determining that the execution result on which the first task to be executed depends does not exist in the execution result storage module, it can also be determined whether the task on which the first task to be executed depends is executed by the main thread based on the execution progress corresponding to the task on which the first task to be executed depends.

[0075] Specifically, if it is determined that the execution progress corresponding to the task on which the first task to be executed depends has not reached the preset progress threshold, the main thread executes the task on which the first task to be executed depends to obtain the execution result of the task; otherwise, the child thread continues to execute the task on which the first task to be executed depends until the task execution is completed and stored in the execution result storage module.

[0076] In an optional implementation, the preset progress threshold can be set based on actual needs. For example, the preset progress threshold can be set to 90%. If it is determined that the execution result on which the first pending task depends does not exist in the execution result storage module, the execution progress of the task on which the first pending task depends is queried. If the execution progress of the task exceeds 90%, it indicates that the task is about to be completed. At this time, the child thread continues to execute the task until the task is completed and stored in the execution result storage module.

[0077] In the embodiment of the present disclosure, after obtaining the execution result of the task on which the first task to be executed depends, the second sub-thread is scheduled to execute the first task to be executed based on the execution result of the task.

[0078] It can be seen that when the embodiment of the present disclosure determines that the execution result on which the first task to be executed depends does not exist in the execution result storage module, the main thread executes the task on which the first task to be executed depends to obtain the execution result of the task, so that the execution result of the task can be obtained before the child thread is scheduled to execute the first task to be executed, which facilitates the subsequent execution of the first task to be executed based on the execution result of the task, further reduces the task execution time in the target scenario, and improves the user experience.

[0079] In actual applications, there may be execution dependencies between tasks in the target scenario. Tasks with execution dependencies have an execution order. Assuming that the execution of task B depends on the execution result of task A, it means that there is an execution dependency between task A and task B, and task B can only be executed when task A is completed.

[0080] In an optional implementation, in order to reduce the total execution time of multiple tasks in the target scenario, different tasks with execution dependencies can also be mounted on different lifecycle nodes. In the process of executing multiple tasks in the target scenario, since there is no execution dependency between different tasks on the same lifecycle node, the tasks mounted on the lifecycle node can be asynchronously executed by scheduling at least one child thread, thereby reducing the execution time of tasks in the target scenario.

[0081] In actual applications, since there is a sequential execution relationship between multiple lifecycle nodes of the target scenario, and there are tasks with execution dependencies among multiple tasks of the target scenario, when determining the correspondence between lifecycle nodes and tasks, it is also necessary to comprehensively consider the two dimensions of the sequential execution relationship of lifecycle nodes and the execution dependency relationship between tasks, and mount the tasks on the corresponding lifecycle nodes.

[0082] In an optional implementation, the multiple lifecycle nodes of the target scenario include a second lifecycle node and a third lifecycle node, wherein the second lifecycle node is executed before the third lifecycle node. In addition, the multiple tasks corresponding to the target scenario include a second task and a third task having an execution dependency relationship, wherein the execution of the third task depends on the execution result of the second task.

[0083] Since the execution order of the second life cycle node is before the third life cycle node, and the execution of the third task depends on the execution result of the second task, the second task can be mounted on the second life cycle node, and the third task can be mounted on the third life cycle node, so that when the main thread executes each life cycle node, it can first schedule the child thread to execute the second task, and after obtaining the execution result of the second task, execute the third task based on the execution result of the second task.

[0084] For example, assume that the life cycle of the target scene is divided into node A1, node A2 and node A3, and the execution order of each node is A1, A2, A3 respectively, and the tasks in the target scene are B1, B2, B3 respectively. Among them, B2 and B3 have an execution dependency relationship, and the execution of B3 depends on the execution result of B2. Therefore, the life cycle nodes corresponding to B2 and B3 can include the following situations: 1. Mount B2 on A1 and mount B3 on A2; 2. Mount B2 on A1 and mount B3 on A3; 3. Mount B2 on A2 and mount B3 on A3.

[0085] It can be seen that the embodiment of the present disclosure mounts tasks with execution dependencies on different lifecycle nodes, so that different tasks mounted on the same lifecycle node can be executed asynchronously based on at least one child thread, thereby further reducing the task execution time in the target scenario.

[0086] In actual applications, when a preset exit event of the first life cycle node is received, the execution status of the tasks mounted on the life cycle node can also be counted so that the number of tasks and / or at least one sub-thread mounted on the life cycle node can be adjusted based on the execution status.

[0087] In an embodiment of the present disclosure, when a preset exit event of the first life cycle node is received, the execution status of the task mounted on the first life cycle node is determined, wherein the execution status is used to reflect whether the task is completed, and then, the execution status of the task mounted on the first life cycle node is sent, wherein the execution status of the task mounted on the first life cycle node is used to update the number of tasks mounted on the first life cycle node and / or at least one sub-thread.

[0088] In the embodiment of the present disclosure, the first lifecycle node may be any lifecycle node in the target scenario.

[0089] In an optional implementation, the execution status of the tasks mounted on the first lifecycle node is sent. Based on the execution status of each task, technicians can evaluate whether the number of sub-threads is reasonable, as well as whether the number of tasks mounted on the first lifecycle node is reasonable, and make corresponding adjustments for unreasonable situations.

[0090] In an optional implementation, the tasks mounted on the first life cycle node can be divided into unfinished tasks and completed tasks based on the execution status of the tasks. If it is determined that the number of unfinished tasks is much larger than the number of completed tasks, it means that the number of tasks mounted on the first life cycle node is large, or the number of at least one sub-thread is small. At this time, the number of tasks mounted on the first life cycle node can be reduced and / or the number of at least one sub-thread can be increased; if it is determined that all the tasks mounted on the first life cycle node are completed, and there are still some idle sub-threads, it means that the number of tasks mounted on the first life cycle node is small, or the number of at least one sub-thread is large. At this time, the number of tasks mounted on the first life cycle node can be increased and / or the number of at least one sub-thread can be reduced.

[0091] It can be seen that the embodiment of the present disclosure can update the number of tasks and / or at least one sub-thread mounted on the first life cycle node based on the execution status of the tasks mounted on the first life cycle node, thereby further reducing the task execution time in the target scenario and improving the user experience.

[0092] Based on the above method embodiment, the present disclosure further provides a task processing device. Referring to FIG3 , which is a structural diagram of a task processing device provided in an embodiment of the present disclosure, the device includes:

[0093] A first determining module 301 is configured to determine, in response to a preset entry event for a first lifecycle node, a task mounted on the first lifecycle node as a task to be executed; wherein the first lifecycle node belongs to a plurality of lifecycle nodes obtained by dividing the lifecycle of a target scenario, the target scenario corresponds to a plurality of tasks, and the plurality of tasks are respectively mounted on the same or different lifecycle nodes in the target scenario;

[0094] The first execution module 302 is configured to schedule at least one sub-thread to execute the task to be executed.

[0095] In an optional embodiment, the device further includes:

[0096] a second determining module configured to, if it is determined that the first task to be executed has execution dependency information, determine whether a dependent execution result of the first task to be executed is currently stored based on the execution dependency information; wherein the execution dependency information carries identification information of the dependent execution result;

[0097] Accordingly, the first execution module includes:

[0098] The execution submodule is configured to schedule a first sub-thread to execute the first task to be executed based on the dependent execution result if it is determined that the dependent execution result of the first task to be executed is currently stored.

[0099] In an optional embodiment, the device further includes:

[0100] a second execution module configured to, if it is determined that no dependent execution result of the first task to be executed is currently stored, execute, by the main thread, the task on which the first task to be executed depends, to obtain the execution result of the task;

[0101] The third execution module is used to schedule the second sub-thread to execute the first task to be executed based on the execution result of the task.

[0102] In an optional embodiment, the device further includes:

[0103] A receiving module, configured to receive a mount request for a first task corresponding to the target scenario; wherein the mount request carries an identifier of a target lifecycle node;

[0104] A mounting module is used to mount the first task to the target lifecycle node.

[0105] In an optional implementation, there is no execution dependency between different tasks mounted on the same lifecycle node of the target scenario.

[0106] In an optional embodiment, the multiple lifecycle nodes include a second lifecycle node and a third lifecycle node, the multiple tasks include a second task and a third task that have an execution dependency relationship, the execution dependency relationship includes a relationship in which the third task depends on the execution of the second task, the second task is mounted on the second lifecycle node, and the third task is mounted on the third lifecycle node.

[0107] In an optional embodiment, the device further includes:

[0108] a third determining module, configured to determine, in response to a preset exit event for the first lifecycle node, an execution status of the task mounted on the first lifecycle node; wherein the execution status is used to reflect whether the task has been completed;

[0109] A sending module is used to send the execution status of the task mounted on the first life cycle node; wherein the execution status of the task mounted on the first life cycle node is used to update the number of tasks mounted on the first life cycle node and / or the at least one sub-thread.

[0110] In the task processing device provided by the embodiment of the present disclosure, when a preset entry event for a first lifecycle node is received, the task mounted on the first lifecycle node is determined as a task to be executed; wherein the first lifecycle node belongs to a plurality of lifecycle nodes obtained by dividing the lifecycle of a target scene, the target scene corresponds to a plurality of tasks, and the plurality of tasks are respectively mounted on the same or different lifecycle nodes in the target scene; and at least one child thread is scheduled to execute the task to be executed. It can be seen that the embodiment of the present disclosure mounts a plurality of tasks on a plurality of lifecycle nodes in advance, and when entering a certain lifecycle node, the task mounted on the lifecycle node is asynchronously executed by scheduling at least one child thread, thereby reducing the time consumption of task execution in the target scene and improving the user experience.

[0111] In addition to the above-mentioned method and apparatus, the embodiment of the present disclosure further provides a computer-readable storage medium, which stores instructions. When the instructions are executed on a terminal device, the terminal device implements the task processing method described in the embodiment of the present disclosure.

[0112] The embodiments of the present disclosure further provide a computer program product, which includes a computer program / instructions. When the computer program / instructions are executed by a processor, the task processing method described in the embodiments of the present disclosure is implemented.

[0113] In addition, the embodiment of the present disclosure further provides a task processing device, as shown in FIG4 , which may include:

[0114] Processor 401, memory 402, input device 403, and output device 404. The task processing device may include one or more processors 401, with one processor being used as an example in FIG4 . In some embodiments of the present disclosure, processor 401, memory 402, input device 403, and output device 404 may be connected via a bus or other means, with FIG4 using a bus as an example.

[0115] The memory 402 can be used to store software programs and modules. The processor 401 executes various functional applications and data processing of the task processing device by running the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, at least one application required for a function, etc. In addition, the memory 402 may include a high-speed random access memory and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device. The input device 403 may be used to receive input digital or character information and generate signal input related to user settings and function control of the task processing device.

[0116] Specifically in this embodiment, the processor 401 will load the executable files corresponding to the processes of one or more applications into the memory 402 according to the following instructions, and the processor 401 will run the applications stored in the memory 402, thereby realizing the various functions of the above-mentioned task processing device.

[0117] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.

[0118] The foregoing description is intended only to provide specific embodiments of the present disclosure, intended to enable those skilled in the art to understand and implement the present disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure is not intended to be limited to the embodiments described herein, but rather to be construed in the broadest manner consistent with the principles and novel features disclosed herein.

Claims

1. A task processing method, include: In response to a preset entry event for a first lifecycle node, determining a task mounted on the first lifecycle node as a task to be executed; wherein the first lifecycle node belongs to a plurality of lifecycle nodes obtained by dividing the lifecycle of a target scenario, the target scenario corresponds to a plurality of tasks, and the plurality of tasks are respectively mounted on the same or different lifecycle nodes in the target scenario; At least one sub-thread is scheduled to execute the task to be executed.

2. The method according to claim 1, wherein the to-be-executed task comprises a first to-be-executed task, and before the scheduling of at least one sub-thread to execute the to-be-executed task, include: If it is determined that the first task to be executed has execution dependency information, determining whether a dependent execution result of the first task to be executed is currently stored based on the execution dependency information; wherein the execution dependency information carries identification information of the dependent execution result; Accordingly, scheduling at least one sub-thread to execute the task to be executed includes: If it is determined that the dependent execution result of the first task to be executed is currently stored, the first sub-thread is scheduled to execute the first task to be executed based on the dependent execution result.

3. The method according to claim 2, wherein the method further include: If it is determined that the dependent execution result of the first task to be executed is not currently stored, the main thread executes the task on which the first task to be executed depends to obtain the execution result of the task; The second sub-thread is scheduled to execute the first task to be executed based on the execution result of the task.

4. The method according to claim 1, wherein before determining the task mounted on the first lifecycle node as the task to be executed in response to the preset entry event of the first lifecycle node, further include: receiving a mount request for a first task corresponding to the target scene; wherein the The mount request carries the identifier of the target lifecycle node; Mount the first task to the target lifecycle node.

5. The method according to claim 1, wherein there is no execution dependency between different tasks mounted on the same lifecycle node of the target scenario.

6. The method according to claim 1, wherein the multiple lifecycle nodes include a second lifecycle node and a third lifecycle node, the multiple tasks include a second task and a third task that have an execution dependency relationship, the execution dependency relationship includes a relationship in which the third task depends on the execution of the second task, the second task is mounted on the second lifecycle node, and the third task is mounted on the third lifecycle node.

7. The method according to claim 1, wherein the method further include: In response to a preset exit event for the first lifecycle node, determining an execution status of a task mounted on the first lifecycle node; wherein the execution status is used to reflect whether the task has been completed; Send the execution status of the task mounted by the first life cycle node; wherein the execution status of the task mounted by the first life cycle node is used to update the number of tasks mounted by the first life cycle node and / or the at least one sub-thread.

8. A task processing device, include: A first determination module is used to determine, in response to a preset entry event for a first lifecycle node, a task mounted on the first lifecycle node as a task to be executed; wherein the first lifecycle node belongs to a plurality of lifecycle nodes obtained by dividing the lifecycle of a target scene, the target scene corresponds to a plurality of tasks, and the plurality of tasks are respectively mounted on the same or different lifecycle nodes in the target scene; The first execution module is used to schedule at least one sub-thread to execute the task to be executed.

9. A computer-readable storage medium, wherein the computer-readable storage medium stores instructions, and when the instructions are executed on a terminal device, the terminal device implements the method according to any one of claims 1 to 7.

10. A task processing device, include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Method and device for opening live broadcast room page and computer equipment

    CN110347952A

  • Task scheduling method and device and computer readable storage medium

    CN113238838A

  • Multi-program collaboration method, system and equipment based on different scenes and medium

    CN114675943A

  • System and method for scheduling thread execution

    US20040187120A1