Operation response method and operation response device
Through operation response strategies for different task states in terminal applications, the loading speed of long information and user experience are improved, the problem of unstable server interface response is solved, and flexible data storage and download strategies are implemented.
Patent Information
- Application Number
- CN202411096219.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-12
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2044-08-12
AI Technical Summary
In terminal applications, there is a long waiting time when loading long information, and the server interface response time is unstable, which affects the user experience.
By receiving the target operation, obtain the task corresponding to the target operation. The tasks include completed data download, unexecuted and ready/executing tasks. Send data requests to the server respectively and wait for the data to be downloaded. Use the data downloaded by each task. In response to the operation, the operation is divided into multiple tasks, and different strategies are used for data preloading or real-time downloading.
It improves the operation response speed and user experience, and provides flexible data storage strategies to adapt to different users and network conditions through the analysis of terminal application user data and functional data.
Smart Images

Figure CN118626234B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of terminal technology, and in particular to an operation response method and an operation response device. Background Art
[0002] In terminal applications such as vehicle control applications, there are some long information. If you rely on entering the page and then making an interface request to obtain data to refresh the interface, there will be a long waiting time. Even if local refresh technology is used to load the information of the local page first, it cannot change the fact that the user experience is damaged.
[0003] Moreover, the server interface request time is not a stable value. Even if the network conditions at the time are not taken into account, different server interfaces have different response times, and the same server interface has different response speeds in different time periods. This will also affect the user experience. Summary of the invention
[0004] In view of this, an embodiment of the present application provides an operation response method and an operation response device to solve the problem of slow response speed to long message operation requests in the prior art.
[0005] According to a first aspect of an embodiment of the present application, an operation response method is provided. The method is executed by a terminal and includes:
[0006] In response to receiving the target operation, obtaining a task corresponding to the target operation, the task including at least one of a first task, a second task and a third task, the first task being a task with a task status of completed data download, the second task being a task with a task status of unexecuted, and the third task being a task with a task status of ready or executing;
[0007] In response to the task including the second task, sending a request to obtain the second task data to the server to download the data of the second task;
[0008] In response to the tasks including the third task, waiting for the third task to complete data downloading;
[0009] Respond to target actions using the data downloaded by each task.
[0010] According to a second aspect of the embodiments of the present application, an operation response device is provided, including:
[0011] an acquisition module, configured to, in response to receiving a target operation, acquire a task corresponding to the target operation, the task comprising at least one of a first task, a second task, and a third task, the first task being a task whose task status is that data downloading has been completed, the second task being a task whose task status is that it has not been executed, and the third task being a task whose task status is that it is ready or being executed;
[0012] A download module is configured to send a request for obtaining second task data to a server in response to the task including the second task, so as to download the data of the second task;
[0013] The download module is further configured to wait for the third task to complete data downloading in response to the third task being included in the tasks;
[0014] The response module is configured to respond to the target operation using the data downloaded by each task.
[0015] The beneficial effect of the embodiment of the present application compared with the prior art is: the embodiment of the present application obtains the task corresponding to the target operation when receiving the target operation, and the task corresponding to the target operation includes at least one of the first task, the second task and the third task, wherein the task data of the first task has been downloaded, the task data of the second task is obtained by the terminal sending an acquisition request to the server, and the task data of the third task is downloaded by the terminal from the server, and finally the data downloaded from each task is used to respond to the operation, so that the operation can be divided into multiple tasks, and different strategies are used for different tasks to preload or download data in real time, thereby improving the response speed of the operation and enhancing the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0017] Figure 1 It is a flowchart of an operation response method provided in an embodiment of the present application.
[0018] Figure 2 It is a flowchart of a method for a server to create a preloading task provided in an embodiment of the present application.
[0019] Figure 3 It is a flowchart of a method for determining task complexity provided in an embodiment of the present application.
[0020] Figure 4 It is a schematic diagram of a logical branch tree provided in an embodiment of the present application.
[0021] Figure 5 It is a flow chart of a method for a server to generate and issue a cleaning instruction according to a cleaning strategy provided in an embodiment of the present application.
[0022] Figure 6 It is a flowchart of a method for determining whether task data download conditions are met, provided in an embodiment of the present application.
[0023] Figure 7 It is a flowchart of a method for determining the value of a free record block provided in an embodiment of the present application.
[0024] Figure 8 It is a response function structure diagram of the interaction detector provided in an embodiment of the present application.
[0025] Fig. 9 It is a correspondence diagram between the business modules and tasks provided in the embodiment of the present application.
[0026] Fig.10 It is a structural diagram of the tasks provided in the embodiments of the present application.
[0027] Fig.11 It is a flowchart of a method for obtaining a task corresponding to a target operation provided in an embodiment of the present application.
[0028] Fig.12 It is a schematic diagram of an operation response device provided in an embodiment of the present application.
[0029] Fig.13 It is a schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0030] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0031] An operation response method and device according to an embodiment of the present application will be described in detail below with reference to the accompanying drawings.
[0032] As mentioned above, in terminal applications such as vehicle control applications, there are some long information. If you rely on entering the page and then making an interface request to obtain data to refresh the interface, there will be a long waiting time. Even if the local refresh technology is used to load the information of the local page first, it cannot change the fact that the user experience is damaged.
[0033] Moreover, the server interface request time is not a stable value. Even if the network conditions at the time are not taken into account, different server interfaces have different response times, and the same server interface has different response speeds in different time periods. This will also affect the user experience.
[0034] In view of this, the embodiment of the present application provides a strategy, combined with the analysis strategy, which can increase the loading speed of pages with long information or long request interface time in terminal applications, significantly improving the user experience. At the same time, through the combination of server distribution, configuration files and client self-intelligent adjustment, the solution has strong flexibility, which is convenient for effective data storage without affecting the performance of the client.
[0035] Furthermore, an embodiment of the present application provides an operation response method, by obtaining a task corresponding to the target operation when a target operation is received, the task corresponding to the target operation includes at least one of a first task, a second task and a third task, wherein the task data of the first task has been downloaded, the task data of the second task is obtained by the terminal sending an acquisition request to the server, and the task data of the third task is downloaded by the terminal from the server, and finally the data downloaded from each task is used to respond to the operation, so that the operation can be divided into multiple tasks, and different strategies are used for data preloading or real-time downloading for different tasks, thereby improving the response speed of the operation and enhancing the user experience.
[0036] Furthermore, different download strategies for tasks are determined based on the terminal application user data and terminal application function data collected by the tracking points set up on the terminal, as well as the idle status of the terminal application main thread and the terminal resource occupancy rate. Different download strategies can be provided for different users, different operations and different network conditions, further improving the response speed of operations.
[0037] Figure 1 Schematic diagram of a process flow of an operation response method provided in an embodiment of the present application. Figure 1 As shown, the method comprises the following steps:
[0038] In step S101 , in response to receiving a target operation, a task corresponding to the target operation is acquired.
[0039] Among them, the task includes at least one of a first task, a second task and a third task. The first task is a task whose task status is completed data download, the second task is a task whose task status is not executed, and the third task is a task whose task status is ready or executing.
[0040] In step S102 , in response to the task including the second task, a request for obtaining second task data is sent to the server to download the data of the second task.
[0041] In step S103, in response to the third task being included in the tasks, the process waits for the third task to complete data downloading.
[0042] In step S104, the data downloaded by each task is used to respond to the target operation.
[0043] In the embodiment of the present application, the operation response method may be executed by a terminal, wherein the operation may be an operation in a terminal application, the terminal detects the user operation, or receives an operation instruction, and then responds to the operation.
[0044] In the embodiment of the present application, when the terminal receives the target operation, the task corresponding to the target operation can be obtained. The task includes at least one of a first task, a second task, and a third task. The first task is a task whose task status is that data downloading has been completed, the second task is a task whose task status is that it has not been executed, and the third task is a task whose task status is ready or in execution. In other words, the target operation can correspond to one or more tasks, and the task status of each task can be completed, unexecuted, ready, or in execution.
[0045] In the embodiment of the present application, when the tasks corresponding to the target operation include the first task, since the data of the first task has been downloaded, there is no need to perform additional operations, and the downloaded data of the first task can be directly used to respond to the operation.
[0046] In the embodiment of the present application, when the task corresponding to the target operation includes the second task, since the second task is an unexecuted task, the terminal can send a request to obtain the second task data to the server to download the data of the second task from the server.
[0047] In the embodiment of the present application, when the tasks corresponding to the target operation include the third task, since the third task is a ready task or a task in execution, the terminal also does not need to perform additional operations and only needs to wait for the third task to complete data downloading.
[0048] In the embodiment of the present application, after the data of all tasks corresponding to the target operation are downloaded, the data downloaded by each task is used to respond to the target operation. In some embodiments, other data can also be used to respond to the target operation, and the other data is real-time download data, which is not downloaded through tasks. The acquisition method of other data can be the same as the acquisition method of the second task, and the terminal sends a request to obtain real-time download data to the server, and the real-time download data is downloaded from the server. Finally, the terminal uses all the data required and downloaded to respond to the target operation to respond to the target operation.
[0049] According to the technical solution provided in the embodiment of the present application, when a target operation is received, a task corresponding to the target operation is obtained, and the task corresponding to the target operation includes at least one of a first task, a second task and a third task, wherein the task data of the first task has been downloaded, the task data of the second task is obtained by the terminal by sending an acquisition request to the server, and the task data of the third task is downloaded by the terminal from the server, and finally the data downloaded from each task is used to respond to the operation, so that the operation can be divided into multiple tasks, and different strategies are used for different tasks to preload or download data in real time, thereby improving the response speed of the operation and enhancing the user experience.
[0050] In the embodiment of the present application, the operation may be a terminal application page operation or a terminal application function operation. If the operation is a terminal application page operation, the target operation of using the data downloaded by each task to respond may be to render the page using the data downloaded by each task. If the operation is a terminal application function operation, the target operation of using the data downloaded by each task to respond may be to call a function or display a function using the data downloaded by each task. In one example, the page may be a secondary page in an application.
[0051] In the embodiment of the present application, each task corresponding to the target operation is a preload task, which is created by the server and sent to the terminal. That is, the server can create multiple pre-download tasks, set a download time for each task, and send the task to the terminal at the set download time so that the terminal downloads the data of the task.
[0052] Figure 2 1 is a flow chart of a method for a server to create a preload task provided by an embodiment of the present application. Figure 2 As shown, the method comprises the following steps:
[0053] In step S201, terminal application user data and terminal application function data are obtained through preset embedding points in the terminal.
[0054] In step S202, based on the terminal application user data and the terminal application function data, long data pages that take longer than a preset time threshold and large data pages that include data content greater than a preset amount are obtained, and preloading tasks are created for the long data pages and large data pages.
[0055] In step S203, data that needs to be prepared in advance is determined, and a preloading task is created for the data that needs to be prepared in advance.
[0056] The data that needs to be prepared in advance includes at least one of the mute function data in the terminal application, the user information in the terminal application, and the privacy protocol in the terminal application.
[0057] In step S204, user usage habits are obtained based on terminal application user data and terminal application function data statistics, and corresponding preloading tasks are created based on the user usage habits.
[0058] In an embodiment of the present application, the server can first obtain terminal application user data and terminal application function data through preset tracking points in the terminal, and obtain long data pages that take longer than a preset time threshold and large data pages that include data content greater than a preset number based on the obtained terminal application user data and terminal application function data, and create preloading tasks for the long data pages and large data pages.
[0059] On the other hand, the server can also obtain data that needs to be prepared in advance and create a preload task for the data that needs to be prepared in advance, wherein the data that needs to be prepared in advance includes at least one of the mute function data in the terminal application, the user information in the terminal application, and the privacy agreement in the terminal application. Finally, the server obtains the user's usage habits based on the terminal application user data and the terminal application function data statistics, and creates a corresponding preload task based on the user's usage habits.
[0060] In other words, you can set up tracking points in the terminal to collect terminal application user data and terminal application function data. Taking the terminal application as a car control application as an example, the data collected by the tracking points may include user action data in the application, user order data in the application, the total number of times different functions are used in the terminal application, the number of times different functions are used in each life cycle of the terminal application, the loading time of different functions, the data usage of different functions, long data function data in the terminal application, mute function data in the terminal application, user information in the terminal application, privacy agreement in the terminal application, post details data in the terminal application and other data.
[0061] Among them, the user's actions in the application may include the user's sharing, collection, adding to the shopping cart and direct ordering of the products in the car mall, as well as the user's participation in community activities, the number of posts viewed, etc. The user's order situation in the application may include the time the user stays on the page corresponding to each step of the operation, the churn rate, the order rate, etc. The data usage of different functions can be the data corresponding to each function is a single use, a fixed number of uses or continuous use.
[0062] Long data function data in terminal applications can include shopping cart data, product details data, etc. The mute function data in terminal applications refers to whether the user is in a mute state, and the post details data in terminal applications can include activity data, post data with multiple images or videos and other time-consuming resources. Other data can be other functions specified by business needs.
[0063] After obtaining the terminal application user data and the terminal application function data, the server may analyze the data and create corresponding tasks for the data that needs to be preloaded, wherein the tasks may include a variety of different types.
[0064] In one implementation, a corresponding preloading task can be created for time-consuming data. In one example, a loading time threshold can be statistically obtained based on the data reported by the embedding point, and a preloading task can be directly created and issued for data that takes longer than the loading time threshold. Among them, the loading time threshold can be set according to actual needs, for example, according to the time requirement, such as directly setting the loading time threshold to 1 second, or according to statistical data, such as according to statistical data, the loading time of most pages with real-time data loading is 500 milliseconds, so the loading time threshold is set to 500 milliseconds.
[0065] In one implementation, corresponding preloading tasks may be created for pages with more data content, such as pages with long images, large amounts of text or videos, such as user privacy agreements, long image activity guides, and the like.
[0066] In one implementation, a corresponding preload task may be created for data that needs to be prepared in advance, wherein the data that needs to be extracted and prepared may include a mute function, user information, or a user privacy agreement.
[0067] In one implementation, user usage habits can also be counted, and corresponding preload tasks can be created based on user usage habits. For example, if statistics show that users frequently use the cache cleaning function, indicating that the user is very concerned about memory usage, the server should give priority to sending tasks with less memory usage, and in terms of data storage, send clients policies that frequently clean up data and have low memory usage. On the other hand, if statistics show that users rarely browse content related to the vehicle community, the server may not send community-related tasks.
[0068] In the embodiment of the present application, the task may include a data usage scenario. Obtaining the task corresponding to the target operation may include determining the scenario of the target operation; and determining the task having the same data usage scenario as the scenario of the target operation as the task corresponding to the target operation.
[0069] Furthermore, the task may also include a priority, which at least includes a time priority order. The time priority order may be determined in the following manner: obtaining terminal application user data and terminal application function data through preset embedding points in the terminal; using the terminal application user data and terminal application function data to determine the task type score, task download timing score, downloaded data volume, stored data volume and task complexity of each task; performing weighted summation of the task type score, task download timing score, downloaded data volume, stored data volume and task complexity to obtain the time priority order of each task.
[0070] That is, the server can set a task priority for the created preload task. The task priority can include a type priority, which can include a mandatory type and an optional type. A mandatory type task refers to a task that must be called once in the life cycle of a terminal application, such as requesting user information; an optional type task refers to a task that can be cut, such as caching a post detail.
[0071] Furthermore, task priority can also include time priority order. Still taking the car control application as an example, when setting the time priority order for tasks, the following factors can be considered: for requesting user information and user vehicle list data, set their time priority order to the front, such as processing them when the application is started; user community permissions (including whether they are banned, the user's friend blacklist, etc.), car mall functions (including whether users can place orders, whether some high-level user (VeryImportant Person, VIP) functions such as price comparison plug-ins are visible to users, etc.) can be loaded later.
[0072] In some implementations, the time priority order can be calculated using a priority calculation model. The priority calculation model can obtain the time priority order of each task by weighted summing up the task type score, task download timing score, downloaded data volume, stored data volume and task complexity.
[0073] The task download timing score is determined in the following manner: obtain the download timing of each task, which includes downloading when the terminal application is started, downloading when the terminal application is idle, and downloading at a specific time node; score each task according to the download timing, where the task with an earlier download timing has a higher download timing score. Downloading at startup includes downloading at the same time as the terminal application is started, and downloading after the terminal application starts and enters the main page.
[0074] In the embodiment of the present application, the download timing of some tasks can be set to download at startup, so they must be executed when the terminal application is started. However, if the task must be executed in the main thread, the execution of the task will inevitably affect the startup speed of the terminal application, thereby affecting the user experience. Therefore, the startup can be divided into two stages: startup and entering the main page.
[0075] Taking the implementation in iOS system as an example, downloading while the terminal application is started means downloading the task data at the same time during didFinishLaunchingWithOptions. Since this period is critical to the loading speed of the application's main page, if it is not a necessary main thread task, it should not be set to start during this period in theory. Downloading after the terminal application starts and enters the main page means downloading the task data after the user has entered the terminal application's main page and can use the homepage.
[0076] The task type score can be a score value obtained by scoring the task according to the task type. The scoring method can be manual scoring or automatic scoring based on statistical results. For example, user data can be 10 points and post data can be 1 point. This is distinguished according to the importance of the task. For example, if the number of page views of each page is: car control < community < mall, the number of page views of each task can be used as the score, or the percentage of the number of page views of each task can be used as the score.
[0077] The task download timing score is the score value obtained based on the task download timing score. The earlier the task download timing, the higher the score. The download data volume is the score value obtained based on the task download data volume score. The smaller the task download data volume, the higher the score. The storage data volume is the score value obtained based on the task storage data volume score. The smaller the task storage data volume, the higher the score.
[0078] Figure 3 FIG. 1 is a flow chart of a method for determining task complexity provided in an embodiment of the present application. Figure 3 As shown, the method comprises the following steps:
[0079] In step S301, the task is broken down into multiple logical steps.
[0080] In step S302, a logic branch tree is constructed according to the association relationship between the logic steps.
[0081] In step S303, a node weight is assigned to each logic step.
[0082] The node weight is determined according to at least one of the time required to execute the logic step, the terminal resource occupancy rate when the logic step is executed, and the number of execution code lines of the logic node.
[0083] In step S304, a trunk weight is assigned to each association relationship.
[0084] The trunk weight is determined according to at least one of the time required to jump from the last logic step connected by the association relationship to the next logic step, the terminal resource occupancy rate when executing the jump operation, and the number of code lines corresponding to the jump operation.
[0085] In step S305, the node weights and trunk weights of the logical branch trees of each task are summed to obtain the task complexity.
[0086] In the embodiment of the present application, when calculating the complexity of a task, the task can be first decomposed into multiple logical steps, and a logical branch tree can be constructed according to the association relationship between the logical steps. The association relationship between the logical steps refers to the jump relationship between the logical steps. For example, if after the execution of logical step A, it is necessary to jump to logical step B to complete the logical task, then logical step A needs to be associated with logical step B.
[0087] In the embodiment of the present application, a node weight can be assigned to each logical step. The node weight is determined based on at least one of the time required to execute the logical step, the terminal resource occupancy rate when the logical step is executed, and the number of lines of code executed by the logical node. A trunk weight can also be assigned to each association relationship. The trunk weight is determined based on at least one of the time required to jump from the previous logical step connected by the association relationship to the next logical step, the terminal resource occupancy rate when performing the jump operation, and the number of lines of code corresponding to the jump operation. Finally, the node weight and trunk weight of the logical branch tree of each task are summed to obtain the task complexity.
[0088] In other words, each task can be decomposed into a single logical step and logical branch. For a logical branch tree, its complexity can be obtained by summing up the node weight and trunk weight, thereby obtaining the task complexity. The value of the node weight can be the time required to execute the node, or the CPU occupancy or memory occupancy during runtime, or the number of lines of code; the value of the trunk weight can be the time required to jump to the next node, such as the time consumed by judgment, or the CPU occupancy or memory occupancy during runtime, or the number of lines of code.
[0089] Figure 4 Schematic diagram of the logical branch tree provided by the embodiment of the present application. Figure 4 As shown in FIG. 1 , the logical branch tree includes multiple nodes and connecting lines between the nodes. The number in each node is the node weight of the node, and the number marked in each connecting line is the trunk weight of the connecting line. By summing the node weight and trunk weight of the logical branch tree, the task complexity can be obtained.
[0090] In the embodiment of the present application, the task can be executed by a task executor, which receives the task data sent by the server, and when it is determined that the task data downloading condition is met, starts the task execution thread to download the task data, and saves the downloaded task data in a preset storage area. Among them, using the data downloaded by each task to respond to the target operation can be to obtain the data downloaded by each task from the preset storage area; and use the obtained data to respond to the operation.
[0091] In an embodiment of the present application, the data structure of the task executor can be a task, and the task can include fields such as task identification (Identity Document, ID), task description, task type, task download timing, data usage scenario, data cleaning strategy, corresponding thread, required thread, priority, status, whether to force execution, etc.
[0092] The task ID can be filled in by the terminal. It is the unique identifier of the task and can be generated using tools such as a Universally Unique Identifier (UUID) generator. The task description is an optional field.
[0093] The task type can be filled in by the server and can be modified by the terminal. The task type can be an identifier used to identify the task, and the identifier must correspond to the server's record. For example, downloading user community information, downloading user basic information, downloading community long picture posts, downloading user privacy agreements, etc. It should be noted that a task of one type can have multiple task instances.
[0094] The task download timing can be filled in by the server and can be modified by the terminal. The content of this field determines whether the task is downloaded when the application is started, when the application is idle, or at a specific time node. Among them, downloading at a specific time node can include, for example, that the task can only be executed after a specific task is executed, or that the task can only be executed after a specific trigger, etc. Further, the specific task can be a task that needs to be completed before the execution of the current task, and the specific trigger can be a trigger used to trigger the current task.
[0095] Data usage scenarios can be filled in by the server and can be modified by the terminal. The content of this field is used to indicate in which scenarios the data of this task is used. For example: the privacy agreement has an entry in the login interface and an entry in the personal center, so there are two scenarios for the privacy agreement.
[0096] The data cleaning strategy can be filled in by the server and modified by the terminal. Each task generates data. For this data, if it is no longer needed in an application life cycle, it can be cleaned up to save memory. The specific cleaning strategy is described in detail later, and will not be repeated here.
[0097] The corresponding thread can be filled in by the terminal. Each task is a sub-thread of the application during the application execution phase (the sub-thread can be further opened according to the specific type of task to form a tree structure). Therefore, each task needs to record the information of the corresponding thread.
[0098] The required threads can also be filled in by the terminal to indicate whether the task needs to be completed on the main thread, or on the child thread, or needs to be mixed, such as the child thread executing the download step and the main thread executing the page update and interaction steps.
[0099] The priority can be filled in by the server and can be modified by the terminal. Although the client can start multiple threads at the same time, the priority of each task is different. The client should select the task with the highest priority in the current task list to start executing.
[0100] The status can be filled in by the terminal. The status of the task can include ready state, paused state, in progress state, completed state and deleted state. Among them, the ready state means that the task initialization action has just been completed, the preparation work is ready, and it can be started at any time; the paused state means that the task is paused; the in progress state means that the task is being executed; the completed state means that a series of operations including downloading data, storage, etc. in the task have been completed; the deleted state means that the task has been set to invalid, or the data has been set to "cleared", which is a logical deletion.
[0101] Whether to enforce can be filled in by the server, and the terminal cannot modify it. For tasks that the server enforces, the timing of task execution may be determined by the terminal or the server, but it must be enforced. In other words, the terminal can decide not to execute certain tasks based on the data, but the terminal cannot refuse mandatory tasks.
[0102] The task executor needs to register the task. That is, the server can send task data multiple times, but deduplication is required on the terminal. Deduplication means that completed tasks or tasks in progress cannot be downloaded again after receiving the task sent by the server again, unless the server has a mandatory download requirement. Therefore, the client can maintain a task pool.
[0103] In an embodiment of the present application, after saving the downloaded task data, the task executor processes the task data in the task execution thread in response to the task data being data that needs to be processed, and stores the processed task data separately in a preset storage area and associates it with the corresponding task.
[0104] That is to say, when executing tasks, the task executor can open a separate thread for each task to perform downloading and processing functions. Downloading means that the task processor requests the server to download data and stores the data in a preset storage area. When storing, the data is stored in a preset storage area. Processing means that for resource files such as videos and pictures that need to be processed, they can be processed in the thread first, and then stored in the preset storage area for standby. It should be noted that since resource files such as videos and pictures occupy a large storage space and are fragmented, they can be stored separately and mounted under one or more tasks. All tasks use a reference to this resource to save memory.
[0105] Among them, the preset storage area means that the terminal application has a configuration file for the downloaded data. For each task, the terminal application can create a special storage area and record it in the form of key-value pairs or singleton objects, so that it can be accessed at any time during the operation of the terminal application program.
[0106] In an embodiment of the present application, the task data in the preset storage area includes a first type of data and a second type of data. The first type of data is data after persistence processing, and the second type of data is temporary data. When the terminal receives a cleaning instruction generated and issued by the server according to the cleaning strategy, the temporary data is deleted from the preset storage area by the terminal.
[0107] In the preset storage area, some data can be persisted. In one example, some data is unchanged and often used by applications, such as privacy protocol data and published posts. Such data should be persisted. Persistence processing includes but is not limited to sandboxes, third-party storage, and local / remote databases. It should be noted that the above data cannot be stored permanently because it may change. For example, if the server requires a mandatory update, that is, a mandatory task is issued, such data must be updated. Alternatively, the persistent data in the preset storage area can also be periodically queried at a low frequency to prevent the data from becoming outdated.
[0108] For another part of data, such as data that may change, it can be directly stored during the life cycle of the terminal application, that is, stored in the memory.
[0109] For the data that has been used in this application, it can be cleaned up in the preset storage area. The server generates a cleanup instruction according to the cleanup strategy and sends the cleanup instruction to the terminal.
[0110] Figure 5 1 is a flow chart of a method for a server to generate and send a cleaning instruction according to a cleaning strategy provided in an embodiment of the present application. Figure 5 As shown, the method comprises the following steps:
[0111] In step S501, in response to the temporary data being single-use data, a life timer is set for the temporary data, and a cleanup instruction is generated when the timer reaches a preset time.
[0112] In step S502, the number of times the temporarily stored data is used is cumulatively counted, and a cleanup instruction is generated when the cumulative count value is greater than or equal to a preset count threshold.
[0113] In step S503, a cleaning instruction is generated periodically.
[0114] In the embodiment of the present application, when the temporarily stored data to be cleared is single-use data, the server can set a life timer for the temporarily stored data and generate a clearing instruction when the timer reaches a preset time. The number of times the temporarily stored data is used can also be accumulated and a clearing instruction can be generated when the accumulated count value is greater than or equal to a preset count threshold. The clearing instruction can also be generated periodically.
[0115] In other words, the server can directly set the life span for data that is only used once, and directly delete it after it has expired. The server can also collect data usage information to obtain an average usage value or a usage value in most cases, and then set a preset counting threshold for data that is used once or multiple times, and immediately delete it when the data is used more than the usage threshold. The server can also periodically clean up all cached data to further save the user's storage space. It should be noted that the above data cleaning strategies are all sent from the server to the terminal, and these strategies can be implemented separately or crosswise, that is, used at the same time, or different strategies can be used by time period, user, or device. For example, for terminals with low configuration and small memory, the server should mainly send strategies that use less memory.
[0116] Figure 6 1 is a flow chart of a method for determining whether a task data download condition is satisfied provided in an embodiment of the present application. Figure 6 As shown, the method comprises the following steps:
[0117] In step S601, the idle state of the main thread of the terminal application is detected.
[0118] In step S602, the terminal resource occupancy rate is detected.
[0119] In step S603, in response to determining that the terminal application main thread is idle and the terminal resource occupancy rate is less than a first preset resource occupancy threshold, it is determined that the task data downloading condition is met.
[0120] In an embodiment of the present application, the idle state of the terminal application main thread and the terminal resource occupancy rate can be detected. When it is determined that the terminal application main thread is idle and the terminal resource occupancy rate is less than a first preset resource occupancy threshold, it is determined that the task data downloading condition is met.
[0121] Among them, determining that the main thread of the terminal application is idle can be by calling a singleton object interaction detector in the terminal, the interaction detector maintains an idle record block, and the idle record block is a memory area that records whether the main thread is idle; in response to determining that the value of the idle record block is idle, determining that the main thread of the terminal application is idle.
[0122] Figure 7 is a flow chart of a method for determining the value of a free record block provided by an embodiment of the present application. Figure 7 As shown, the method comprises the following steps:
[0123] In step S701, the terminal receives the tasks sent by the server and generates a task queue list, which is arranged according to the task execution order.
[0124] In step S702, in response to the number of queued tasks in the task queue list being zero, when each task in the queue list is executed, the value of the free record block is modified to not free, and after each task in the queue list is executed, the value of the free record block is modified to free.
[0125] In step S703, in response to the number of queued tasks in the task queue list being not zero, other tasks in the queue list except the currently executing task and the last queued task are discarded, and when the currently executing task and the last queued task are executed, the value of the free record block is modified to not free, and after the currently executing task and the last queued task are completed, the value of the free record block is modified to free.
[0126] In the embodiment of the present application, since the main thread of the terminal application must be in a non-idle state when the terminal interacts with the user, whether the terminal is idle can be determined by detecting whether the interaction is occurring.
[0127] In an embodiment of the present application, a singleton object can be constructed in the terminal as an interaction detector. The interaction detector maintains an independent memory area, which is locked for protection. All tasks queue up and modify it in an orderly manner according to the order of access time. The independent memory area can be called a free record block. The free record block can exist as a member attribute of the interaction detector, or it can be an independent public variable. For example, task A can set the value of the free record block to not idle. After a period of time, task B can set the value of the free record block to idle. After another period of time, task C can set the value of the free record block to idle... There is always only one value of the free record block, either idle or not idle.
[0128] Furthermore, since the interaction occurs on the main thread, although the user can click repeatedly, they are generally based on the timeline and have a sequence. Therefore, whether it is idle is always based on the last state. As mentioned above, the access of each task to the idle record block protected by the lock is queued, so the number in the queue should always be equal to 0.
[0129] For example, when task A is changing the value of the free record block, task B arrives. If the number of queued tasks in the queue is 0 at this time, task B enters the queue, and the number of queued tasks in the queue becomes 1. Then task C arrives. Since the number of queued tasks in the queue is 1 at this time, task B in the queue should be discarded, so that the number of queued tasks in the queue is 0, and then task C is added to the queue, and the number of queued tasks in the queue becomes 1 again. When task A completes the modification and exits the queue, task C exits the queue and modifies the value of the free record block. At this time, the number of queued tasks in the queue is 0.
[0130] To determine whether an interaction is occurring, you can use method exchange technology to obtain the addresses of all user interaction response functions in the application. In other words, the response function provided by the interaction detector overrides the original response function. Any custom processing can be performed inside it, and of course the original response function can also be called. Among them, method exchange technology can also be replaced by hooks, runtime dynamic detection technology (NSkey Value Observing, KVO, KeyValue Coding, KVC), decompilation technology, aspect technology and other similar technologies, which are not limited here.
[0131] Figure 8 is a response function structure diagram of the interactive detector provided in the embodiment of the present application. Figure 8As shown, the response function of the interactive detector includes a custom logic and an original response function, wherein the custom logic can be one or more. When the response function is triggered, the interactive detector executes the following logic: the interactive detector modifies the idle record block record: the system is no longer idle; executes the original response function; the interactive detector modifies the idle record block record: the system may be idle.
[0132] In an embodiment of the present application, the method for determining the value of the free record block also includes: calling a thread activity state judgment function in the terminal operating system to obtain the main thread state of the terminal application; in response to the obtained terminal application main thread state being inconsistent with the value of the free record block, using the obtained terminal application main thread state value to modify the value of the free record block.
[0133] In other words, the interaction detector can provide positive evidence as reverse evidence. Taking the implementation in the Apple operating system (iPhone Operate System, iOS) system as an example, the main thread can be directly called to detect the isAlive() function. That is, if the idle record block is recorded as idle, but the function returns not idle when the main thread calls the isAlive() function for detection, the idle record block record is modified to be not idle; if the idle record block is recorded as not idle, but the function returns idle when the main thread calls the isAlive() function for detection, the idle record block record is modified to be idle. The isAlive() function can be called regularly to check and correct the value of the idle record block.
[0134] In the embodiment of the present application, since the task needs to be executed under the main line of the application or in a newly opened thread, the terminal performance needs to be considered when determining whether the task data meets the download conditions. In one example, one or more of the terminal central processing unit (CPU) occupancy rate, memory occupancy, startup time, battery power consumption and other performances can be detected to assist in determining whether the task data meets the download conditions.
[0135] Taking the implementation in iOS system as an example, when detecting CPU usage, you can use the system function task_threads to obtain the list of all current threads. Then traverse the thread list, use the system function thread_info to query the information of the specified thread and sum it up. The thread_info function will get a structure of type thread_basic_info_t, which has a member attribute: cpu_usage, which is the CPU usage of the thread. Add up all cpu_usage values in the thread list to get the total CPU usage of the terminal application.
[0136] You can set a preset threshold. If the CPU usage exceeds the preset threshold, no new task thread can be opened, or a task that has started but has a lower priority will be paused until the CPU usage reaches the standard. Only then can a new task be started or a paused task be continued.
[0137] Taking the implementation in iOS system as an example, when detecting memory occupancy, the system function task_info is used to obtain the current list of all threads, the first parameter is passed to mach_task_self(), and the second parameter is passed to TASK_VM_INFO. From the obtained list of all threads, a task_vm_info_data_t structure is obtained, and its member attribute phys_footprint is accessed to obtain the current memory occupancy.
[0138] You can also set a preset threshold. If the memory usage exceeds the preset threshold, no new task thread can be opened, or a task that has started but has a lower priority will be paused until the memory usage reaches the standard, then a new task can be started, or a paused task can be continued.
[0139] In an embodiment of the present application, in response to the task executor determining that the terminal resource occupancy rate is greater than or equal to a second preset resource occupancy threshold when executing a task data operation of the first target task, the download of the first target task data is suspended, the task state of the first target task is modified to a suspended state, and the first target task is added to the suspended task queue of the task executor; in response to the task executor determining that the terminal resource occupancy rate is less than a third preset resource occupancy threshold, the second target task is determined from the suspended task queue, and the task data download operation is continued for the second target task.
[0140] The first target task is the same as or different from the second target task. The second preset resource occupation threshold is less than or equal to the first preset resource occupation threshold, and the third preset resource occupation threshold is less than or equal to the second preset resource occupation threshold.
[0141] That is to say, before each task is started, the operation of obtaining the CPU usage and memory usage can be performed first, and it can be determined whether the CPU usage and memory usage exceed the preset threshold. When any one of the CPU usage and memory usage exceeds or approaches the preset threshold, it is determined that the task data does not meet the download conditions. At this time, the task that has started but has a lower priority can be paused, and the paused task can be added to the pause queue. Subsequently, the operation of obtaining the CPU usage and memory usage is performed regularly. When it is determined that the CPU usage and memory usage do not exceed the preset threshold and are far from the preset threshold, a task can be taken out of the pause queue and started again.
[0142] In the embodiment of the present application, a terminal application page or a terminal application function may correspond to a business module. In other words, a business module may be a terminal application secondary page or a function of a terminal application. Fig. 9 : is a diagram showing the correspondence between the business modules and tasks provided in the embodiment of the present application. Fig. 9 As shown, the business module and the task can be a one-to-many relationship, and a business module can correspond to task 1, task 2, ..., task n, where n is a positive integer. It is understandable that the specific number of tasks corresponding to the business module varies according to its own business needs and is not limited here.
[0143] Furthermore, a task can be split into multiple tasks, multiple tasks can be merged into one task, and there can be parent-child or brother relationships between tasks. Fig.10 is a structural diagram of the tasks provided in the embodiment of the present application. Fig.10 As shown, tasks can also form a tree structure. Among them, the relationship between tasks can be changed, and this change can be directly changed by the server and sent to the client, or directly changed by the client and synchronized to the server.
[0144] When the business module is in use, it first determines whether the relevant task has been completed. If so, it is used directly. If the task is in the ready state, it starts to execute the task until it is completed. At this point, the task is executed as a regular request of a business module and is no longer a preset, optional step. If the task is in the ongoing state, it waits until it is completed. If the task is in the paused state, it is moved to the head of the queue and immediately dequeued and continued to execute until it is completed.
[0145] In the embodiment of the present application, the connection between a task and its corresponding business module can be bridged by using variables.
[0146] Fig.11 FIG. 1 is a flow chart of a method for obtaining a task corresponding to a target operation provided in an embodiment of the present application. Fig.11 As shown, the method comprises the following steps:
[0147] In step S1101, the value of a preset variable of a business module corresponding to a target operation is obtained.
[0148] In step S1102, the task corresponding to the target operation is determined according to the value of the preset variable.
[0149] The value of the preset variable is determined by the method of setting the object attribute value of the preset variable according to the environmental context conditions corresponding to the target operation and the historical value of the preset variable.
[0150] In the embodiment of the present application, after obtaining the target operation, the terminal can further obtain the value of the preset variable of the business module corresponding to the target operation, and then determine the task corresponding to the target operation according to the value of the preset variable.
[0151] The value of the preset variable is determined by the method of setting the object attribute value of the preset variable according to the environmental context conditions corresponding to the target operation and the historical value of the preset variable.
[0152] That is to say, in the embodiment of the present application, a member variable A can be added to the business module, and the member variable A can represent several branch logic processes under a task, or a local area on a page, or several subtasks under a task. Therefore, the member variable A can be a Boolean value in implementation, representing two situations, or an enumeration value, representing multiple situations.
[0153] The method for setting the object property value (setter) of member variable A can be rewritten, and the accepted input parameters are the current conditions, which include the current environment context and the new and old values currently set for member variable A. The logic of the setter method is: judge the value of A, and execute different branch codes according to different values. It should be noted that each member variable is only responsible for its own domain, so a page is divided into small domains, which not only achieves efficient local refresh, but also achieves domainization and independence, making local changes of functions possible. Finally, where the task is triggered, modify the corresponding value of member variable A to determine the task corresponding to the target operation.
[0154] It should be noted that in some programming languages, since some of the above steps can be automatically implemented, they can be further simplified. For example, in the iOS system, if you use the SwiftUI framework for development, you no longer need to manually rewrite the setter method, but if you use Objective-C or Swift for application development, there is no such convenience.
[0155] In the embodiment of the present application, the task also includes a fourth task, and the fourth task is a task whose task status is to suspend data downloading. At this time, the operation response method also includes: sending an activation fourth task message to the server to obtain data of the fourth task. The data response operation is performed using the data downloaded by each task including the data of the fourth task.
[0156] With the technical solution of the embodiment of the present application, each variable is only responsible for its own field, so a page is divided into small fields, which not only realizes efficient local refresh, but also achieves fieldization and independence, making local changes of functions possible. With the technical solution of the embodiment of the present application, users can enter post details, car control pages, etc. in seconds, which greatly improves the user experience and does not significantly affect the performance of the application.
[0157] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present application, which will not be described one by one here.
[0158] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.
[0159] Fig.12 Schematic diagram of an operation response device provided in an embodiment of the present application. Fig.12 As shown, the device comprises:
[0160] The acquisition module 1201 is configured to acquire the task corresponding to the target operation in response to receiving the target operation, the task including at least one of a first task, a second task and a third task, the first task is a task whose task status is that data download has been completed, the second task is a task whose task status is that it has not been executed, and the third task is a task whose task status is that it is ready or executing.
[0161] The download module 1202 is configured to send a request for obtaining second task data to the server in response to the task including the second task, so as to download the data of the second task.
[0162] The download module 1202 is further configured to wait for the third task to complete data downloading in response to the third task being included in the tasks.
[0163] The response module 1203 is configured to respond to the target operation using the data downloaded by each task.
[0164] According to the technical solution provided in the embodiment of the present application, when a target operation is received, a task corresponding to the target operation is obtained, and the task corresponding to the target operation includes at least one of a first task, a second task and a third task, wherein the task data of the first task has been downloaded, the task data of the second task is obtained by the terminal by sending an acquisition request to the server, and the task data of the third task is downloaded by the terminal from the server, and finally the data downloaded from each task is used to respond to the operation, so that the operation can be divided into multiple tasks, and different strategies are used for different tasks to preload or download data in real time, thereby improving the response speed of the operation and enhancing the user experience.
[0165] In the embodiment of the present application, the operation is a terminal application page operation or a terminal application function operation; in response to the operation being a terminal application page operation, the target operation of using the data downloaded by each task is to render the page using the data downloaded by each task; in response to the operation being a terminal application function operation, the target operation of using the data downloaded by each task is to call a function or display a function using the data downloaded by each task.
[0166] In an embodiment of the present application, each task is a preloading task, which is created by a server and sent to a terminal; the server creates a preloading task, including: obtaining terminal application user data and terminal application function data through preset embedding points in the terminal; obtaining long data pages that take longer than a preset time threshold and large data pages that include data content greater than a preset number of values based on statistics of the terminal application user data and terminal application function data, and creating preloading tasks for the long data pages and large data pages; determining data that needs to be prepared in advance, and creating a preloading task for the data that needs to be prepared in advance, wherein the data that needs to be prepared in advance includes at least one of the mute function data in the terminal application, the user information in the terminal application, and the privacy agreement in the terminal application; obtaining user usage habits based on statistics of the terminal application user data and the terminal application function data, and creating corresponding preloading tasks based on the user usage habits.
[0167] In an embodiment of the present application, a task includes a data usage scenario; obtaining a task corresponding to a target operation includes: determining the scenario of the target operation; and determining that a task having the same data usage scenario as the scenario of the target operation is the task corresponding to the target operation.
[0168] In an embodiment of the present application, a task includes a priority, and the priority includes at least a time priority order; the time priority order is determined in the following manner: terminal application user data and terminal application function data are obtained through preset tracking points in the terminal; the terminal application user data and terminal application function data are used to determine the task type score, task download timing score, downloaded data volume, stored data volume and task complexity of each task; the task type score, task download timing score, downloaded data volume, stored data volume and task complexity are weighted and summed to obtain the time priority order of each task.
[0169] In an embodiment of the present application, the task download timing score is determined in the following manner: obtain the download timing of each task, the download timing includes downloading when the terminal application is started, downloading when the terminal application is idle, and downloading at a specific time node; score each task according to the download timing, wherein the task with an earlier download timing has a higher download timing score; wherein downloading at startup includes downloading at the same time as the terminal application is started, and downloading after the terminal application starts and enters the main page.
[0170] In an embodiment of the present application, the task complexity is determined in the following manner: decomposing the task into multiple logical steps; constructing a logical branch tree according to the association relationship between each logical step; assigning a node weight to each logical step, and the node weight is determined based on at least one of the time required to execute the logical step, the terminal resource occupancy when the logical step is executed, and the number of execution code lines of the logical node; assigning a trunk weight to each association relationship, and the trunk weight is determined based on at least one of the time required to jump from the previous logical step connected by the association relationship to the next logical step, the terminal resource occupancy when performing the jump operation, and the number of code lines corresponding to the jump operation; summing the node weights and trunk weights of the logical branch tree of each task to obtain the task complexity.
[0171] In an embodiment of the present application, tasks are executed by a task executor; the task executor receives task data sent by a server, and in response to determining that a condition for downloading task data is met, starts a task execution thread to download task data, and saves the downloaded task data in a preset storage area; uses the data downloaded by each task to respond to target operations, including: obtaining the data downloaded by each task from a preset storage area; and using the obtained data to respond to operations.
[0172] In an embodiment of the present application, after saving the downloaded task data, the task executor processes the task data in the task execution thread in response to the task data being data that needs to be processed, and stores the processed task data separately in a preset storage area and associates it with the corresponding task.
[0173] In an embodiment of the present application, the task data in the preset storage area includes a first type of data and a second type of data, the first type of data is data after persistence processing, and the second type of data is temporary data. When the terminal receives a cleaning instruction generated and issued by the server according to a cleaning strategy, the temporary data is deleted from the preset storage area by the terminal; wherein the server generates and issues a cleaning instruction according to the cleaning strategy, including: in response to the temporary data being single-use data, setting a life length timer for the temporary data, and generating a cleaning instruction when the timer reaches a preset time length; and / or accumulating a count of the number of times the temporary data is used, and generating a cleaning instruction when the accumulated count value is greater than or equal to a preset count threshold; and / or periodically generating a cleaning instruction.
[0174] In an embodiment of the present application, determining whether the task data downloading condition is met includes: detecting the idle status of the terminal application main thread; detecting the terminal resource occupancy rate; in response to determining that the terminal application main thread is idle and the terminal resource occupancy rate is less than a first preset resource occupancy threshold, determining that the task data downloading condition is met.
[0175] In an embodiment of the present application, determining that the main thread of a terminal application is idle includes: calling a singleton object interaction detector in the terminal, the interaction detector maintaining an idle record block, the idle record block being a memory area that records whether the main thread is idle; in response to determining that the value of the idle record block is idle, determining that the main thread of the terminal application is idle; wherein the value of the idle record block is determined in the following manner: the terminal receives a task sent by a server, generates a task queue list, and the task queue list is arranged according to the order in which the tasks are executed; in response to the number of queued tasks in the task queue list being zero, when each task in the queue list is executed, the value of the idle record block is modified to be not idle, and after each task in the queue list is executed, the value of the idle record block is modified to be idle; in response to the number of queued tasks in the task queue list being not zero, discarding other tasks in the queue list except the currently executed task and the last queued task, and when the currently executed task and the last queued task are executed, the value of the idle record block is modified to be not idle, and after the currently executed task and the last queued task are executed, the value of the idle record block is modified to be idle.
[0176] In an embodiment of the present application, the method for determining the value of the free record block also includes: calling a thread activity status judgment function in the terminal operating system to obtain the main thread status of the terminal application; in response to the obtained terminal application main thread status being inconsistent with the value of the free record block, using the obtained terminal application main thread status value to modify the value of the free record block.
[0177] In an embodiment of the present application, in response to the task executor determining that the terminal resource occupancy rate is greater than or equal to a second preset resource occupancy threshold when performing a task data operation on the first target task, the download of the first target task data is suspended, the task state of the first target task is modified to a suspended state, and the first target task is added to the suspended task queue of the task executor; in response to the task executor determining that the terminal resource occupancy rate is less than a third preset resource occupancy threshold, the second target task is determined from the suspended task queue, and the task data download operation is continued for the second target task; wherein the first target task is the same as or different from the second target task; the second preset resource occupancy threshold is less than or equal to the first preset resource occupancy threshold, and the third preset resource occupancy threshold is less than or equal to the second preset resource occupancy threshold.
[0178] In an embodiment of the present application, a terminal application page or a terminal application function corresponds to a business module; obtaining a task corresponding to a target operation includes: obtaining the value of a preset variable of the business module corresponding to the target operation; determining the task corresponding to the target operation according to the value of the preset variable; wherein the value of the preset variable is determined by a method for setting an object attribute value of the preset variable, according to the environmental context conditions corresponding to the target operation and the historical value of the preset variable.
[0179] In an embodiment of the present application, the task also includes a fourth task, and the fourth task is a task whose task status is to suspend data download; the download module is also configured to send an activation message of the fourth task to the server to obtain data of the fourth task; the response module is also configured to use the data downloaded by each task including the data of the fourth task to respond to the operation.
[0180] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0181] Fig.13 Schematic diagram of an electronic device provided in an embodiment of the present application. Fig.13 As shown, the electronic device 13 of this embodiment includes: a processor 1301, a memory 1302, and a computer program 1303 stored in the memory 1302 and executable on the processor 1301. When the processor 1301 executes the computer program 1303, the steps in the above-mentioned method embodiments are implemented. Alternatively, when the processor 1301 executes the computer program 1303, the functions of the modules / units in the above-mentioned device embodiments are implemented.
[0182] The electronic device 13 may be a desktop computer, a notebook, a PDA, a cloud server, or other electronic device. The electronic device 13 may include, but is not limited to, a processor 1301 and a memory 1302. Those skilled in the art will appreciate that Fig.13 The electronic device 13 is merely an example and does not limit the electronic device 13 , and may include more or fewer components than those shown in the figure, or different components.
[0183] The processor 1301 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0184] The memory 1302 may be an internal storage unit of the electronic device 13, for example, a hard disk or memory of the electronic device 13. The memory 1302 may also be an external storage device of the electronic device 13, for example, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card (FlashCard), etc. equipped on the electronic device 13. The memory 1302 may also include both an internal storage unit of the electronic device 13 and an external storage device. The memory 1302 is used to store computer programs and other programs and data required by the electronic device.
[0185] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units.
[0186] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. The computer program may include computer program code, which may be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc.
[0187] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. An operation response method, It is characterized in that The method is executed by a terminal, and includes: In response to receiving the target operation, a task corresponding to the target operation is obtained, the task including at least one of a first task, a second task and a third task, each task being a preloaded task, created by a server and sent to the terminal, the first task being a task with a task status of completed data download, the second task being a task with a task status of unexecuted, and the third task being a task with a task status of ready or executing; In response to the tasks including a second task, sending a request for obtaining second task data to a server to download data of the second task; In response to the tasks including a third task, waiting for the third task to complete data downloading; Using the data downloaded by each task to respond to the target operation; Wherein, the target operation is a terminal application page operation or a terminal application function operation; In response to the target operation being a terminal application page operation, the using the data downloaded by each task to respond to the target operation is to render the page using the data downloaded by each task; In response to the target operation being a terminal application function operation, the use of the data downloaded by each task in response to the target operation is to call the function or display the function using the data downloaded by each task.
2. The method according to claim 1, It is characterized in that The server creates a preload task, including: Acquire terminal application user data and terminal application function data through preset embedding points in the terminal; According to the terminal application user data and the terminal application function data, long data pages that take longer than a preset time threshold and large data pages that include data content greater than a preset amount of value are obtained, and preloading tasks are created for the long data pages and large data pages; Determine data that needs to be prepared in advance, and create a preloading task for the data that needs to be prepared in advance, wherein the data that needs to be prepared in advance includes at least one of mute function data in the terminal application, user information in the terminal application, and a privacy agreement in the terminal application; The user usage habits are obtained according to the terminal application user data and the terminal application function data statistics, and the corresponding preloading tasks are created according to the user usage habits.
3. The method according to claim 1, It is characterized in that Tasks include data usage scenarios; The obtaining of the task corresponding to the target operation includes: Determine the scenario for the target operation; Determine a task having the same data usage scenario as the scenario of the target operation as the task corresponding to the target operation.
4. The method according to claim 1, It is characterized in that The tasks include priorities, the priorities including at least a time priority order; The time priority order is determined as follows: Acquire terminal application user data and terminal application function data through preset embedding points in the terminal; Determine the task type score, task download timing score, download data volume, storage data volume and task complexity of each task using the terminal application user data and the terminal application function data; The task type score, task download timing score, downloaded data volume, stored data volume and task complexity are weighted and summed to obtain the time priority order of each task.
5. The method according to claim 4, It is characterized in that The task download timing score is determined as follows: Obtaining a downloading time for each task, wherein the downloading time includes downloading when the terminal application is started, downloading when the terminal application is idle, and downloading at a specific time node; Scoring each task according to the download timing, wherein the task with an earlier download timing has a higher download timing score; The downloading at startup includes downloading when the terminal application is started, and downloading after the terminal application is started and enters the main page. The specific time node includes after a specific task is executed or after a specific trigger.
6. The method according to claim 4, It is characterized in that The task complexity is determined in the following way: Break down the task into logical steps; Construct a logical branch tree based on the association relationship between each logical step; Assigning a node weight to each logic step, wherein the node weight is determined according to at least one of the time required to execute the logic step, the terminal resource occupancy rate when the logic step is executed, and the number of execution code lines of the logic node; Assign a trunk weight to each association relationship, wherein the trunk weight is determined according to at least one of the time required for jumping from a previous logic step connected by the association relationship to a next logic step, the terminal resource occupancy rate when executing the jump operation, and the number of code lines corresponding to the jump operation; The node weights and trunk weights of the logical branch trees of each task are summed to obtain the task complexity.
7. The method according to claim 1, It is characterized in that Tasks are executed by the Task Executor; The task executor receives the task data sent by the server, and in response to determining that the task data downloading condition is met, starts the task execution thread to download the task data, and saves the downloaded task data in a preset storage area; The using the data downloaded by each task to respond to the target operation includes: Obtaining the data downloaded by each task from the preset storage area; The target operation is responded to using the acquired data.
8. The method according to claim 7, It is characterized in that After saving the downloaded task data, the task executor processes the task data in the task execution thread in response to the task data being data that needs to be processed, and stores the processed task data separately in the preset storage area and associates it with the corresponding task.
9. The method according to claim 7, It is characterized in that The task data in the preset storage area includes first type data and second type data, the first type data is data after persistence processing, and the second type data is temporary data, and the temporary data is deleted from the preset storage area by the terminal when the terminal receives a cleaning instruction generated and issued by the server according to the cleaning strategy; The server generates and issues a cleaning instruction according to the cleaning strategy, including: In response to the temporary data being single-use data, setting a life timer for the temporary data, and generating a cleanup instruction when the timer reaches a preset time; and / or Accumulate and count the number of times the temporarily stored data is used, and generate a cleanup instruction when the accumulated count value is greater than or equal to a preset count threshold; and / or Generate cleanup instructions periodically.
10. The method according to claim 7, It is characterized in that The determining that the task data downloading condition is met includes: Detect the idle status of the main thread of the terminal application; Detect terminal resource occupancy rate; In response to determining that the terminal application main thread is idle and the terminal resource occupancy rate is less than a first preset resource occupancy threshold, it is determined that the task data download condition is met.
11. The method according to claim 10, It is characterized in that The determining that the terminal application main thread is idle includes: A singleton object interaction detector in a calling terminal is used to maintain an idle record block, where the idle record block is a memory area that records whether the main thread is idle. In response to determining that the value of the idle record block is idle, determining that the terminal application main thread is idle; The value of the free record block is determined as follows: The terminal receives the tasks sent by the server and generates a task queue list, wherein the task queue list is arranged according to the order in which the tasks are executed; In response to the number of queued tasks in the task queue list being zero, when each task in the queue list is executed, modifying the value of the free record block to be not free, and after each task in the queue list is executed, modifying the value of the free record block to be free; In response to the number of queued tasks in the task queue list being not zero, other tasks in the queue list except the currently executing task and the last queued task are discarded, and when the currently executing task and the last queued task are executed, the value of the free record block is modified to not free, and after the currently executing task and the last queued task are completed, the value of the free record block is modified to free.
12. The method according to claim 11, It is characterized in that The method for determining the value of the free record block also includes: Calling a thread activity status determination function in the terminal operating system to obtain the main thread status of the terminal application; In response to the obtained terminal application main thread state being inconsistent with the value of the free record block, the value of the free record block is modified using the obtained terminal application main thread state value.
13. The method according to claim 10, It is characterized in that In response to the task executor determining that the terminal resource occupancy rate is greater than or equal to a second preset resource occupancy threshold when executing the task data operation of the first target task, suspending the download of the first target task data, modifying the task state of the first target task to a suspended state, and adding the first target task to the suspended task queue of the task executor; In response to the task executor determining that the terminal resource occupancy rate is less than a third preset resource occupancy threshold, determining a second target task from the suspended task queue, and continuing to perform the task data download operation on the second target task; The first target task is the same as or different from the second target task; The second preset resource occupation threshold is less than or equal to the first preset resource occupation threshold, and the third preset resource occupation threshold is less than or equal to the second preset resource occupation threshold.
14. The method according to claim 1, It is characterized in that A terminal application page or a terminal application function corresponds to a business module; The obtaining of the task corresponding to the target operation includes: Get the value of the preset variable of the business module corresponding to the target operation; Determining the task corresponding to the target operation according to the value of the preset variable; The value of the preset variable is determined by a method for setting an object attribute value of the preset variable according to an environmental context condition corresponding to the target operation and a historical value of the preset variable.
15. The method according to claim 1, It is characterized in that The tasks further include a fourth task, and the fourth task is a task whose task status is to suspend data downloading; The method further comprises: Sending a message to activate the fourth task to the server to obtain data of the fourth task; The target operation is responded to using the data downloaded by each task including the data of the fourth task.
16. An operation response device, It is characterized in that include: an acquisition module, configured to, in response to receiving a target operation, acquire a task corresponding to the target operation, the task comprising at least one of a first task, a second task and a third task, each task being a preloaded task, created by a server and sent to a terminal, the first task being a task whose task status is that data downloading has been completed, the second task being a task whose task status is that it has not been executed, and the third task being a task whose task status is that it is ready or being executed; a download module, configured to send a request for obtaining second task data to a server in response to the task including a second task, so as to download data of the second task; The download module is further configured to, in response to the tasks including a third task, wait for the third task to complete data downloading; A response module, configured to respond to the target operation using the data downloaded by each task; Wherein, the target operation is a terminal application page operation or a terminal application function operation; In response to the target operation being a terminal application page operation, the using the data downloaded by each task to respond to the target operation is to render the page using the data downloaded by each task; In response to the target operation being a terminal application function operation, the use of the data downloaded by each task in response to the target operation is to call the function or display the function using the data downloaded by each task.
