A task scheduling method, device, storage medium and electronic device
By implementing task scheduling methods in the browser, and through delay and secondary deduplication mechanisms, the problem of excessive computing resources occupied by high-frequency interaction of the front-end page of the browser is solved, improving the performance and stability of the browser.
Patent Information
- Application Number
- CN202510274623.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-10
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2045-03-10
AI Technical Summary
In the case of high-frequency interaction of the front-end page of the browser, single-threaded tasks in the javascript language cause excessive computing resources to occupy, resulting in page stuttering or crashing.
By implementing a task scheduling method in the browser, including querying whether there is the same waiting state task within the set time, setting the delay waiting state, and performing secondary deduplication when the browser thread is idle, ensuring that the task is executed uniquely.
Reduces the execution of repeated computing tasks, reduces the consumption of computing resources, improves the performance and stability of the browser, and avoids lag and crashes.
Smart Images

Figure CN119781945B_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of computer technology, and in particular, to a task scheduling method, apparatus, storage medium, and electronic device. Background Art
[0002] In the front-end page of a browser, there may be many high-frequency interaction situations, such as a user continuously clicking a button, quickly resizing a window, or quickly dragging a page element.
[0003] Since the front-end page is generally written in the JavaScript language, and the JavaScript language only supports single-threaded tasks. Therefore, in the case of high-frequency interactions, computing tasks are repeatedly triggered, and the event functions for executing computing tasks are frequently called, which will consume a large amount of computing resources, easily cause the page to freeze, and even cause the web page to crash, affecting the performance of the browser front-end page.
[0004] How to improve the performance of the browser front-end page in the case of high-frequency interactions is an urgent problem to be solved. Summary of the Invention
[0005] This specification provides a task scheduling method, apparatus, storage medium, and electronic device to at least partially solve the above problems existing in the prior art.
[0006] This specification adopts the following technical solutions:
[0007] This specification provides a task scheduling method, applied to a browser, including:
[0008] In response to receiving a target task triggered by a user's interaction operation on the browser front-end page, determine whether there is a computing task in a waiting state that is the same as the target task within a set time;
[0009] If not, set the target task to the waiting state;
[0010] After the waiting state of the target task ends, when it is determined that there is no computing task in the tasks to be executed that is the same as the target task, add the target task to the tasks to be executed, where the tasks to be executed are computing tasks that wait to be executed when the browser thread is idle.
[0011] Optionally, determining whether there is a computing task in a waiting state that is the same as the target task within a set time includes:
[0012] In a first queue, query whether there is a computing task that is the same as the target task, where the first queue stores computing tasks in a waiting state;
[0013] If not, set the target task to the waiting state, specifically including:
[0014] If not, add the target task to the first queue and set a delay time for the target task;
[0015] The method further includes:
[0016] If so, terminate the target task.
[0017] Optionally, query whether there is a computing task identical to the target task, specifically including:
[0018] According to the interaction operation of the user on the browser front-end page, determine the event function and computing parameters corresponding to the target task, where the computing parameters are the input parameters of the event function;
[0019] Determine whether there is a computing task in the first queue whose corresponding event function and computing parameters are both identical to the target task.
[0020] Optionally, before adding the target task to the tasks to be executed when it is determined that there is no computing task identical to the target task among the tasks to be executed, the method further includes:
[0021] Determine whether there are tasks to be executed;
[0022] When it is determined that there is no computing task identical to the target task among the tasks to be executed, adding the target task to the tasks to be executed specifically includes:
[0023] When there are tasks to be executed and it is determined that there is no computing task identical to the target task among the tasks to be executed, add the target task to the tasks to be executed;
[0024] When there are no tasks to be executed, add the target task to the tasks to be executed.
[0025] Optionally, the tasks to be executed are stored in a second queue;
[0026] When it is determined that there is no computing task identical to the target task among the tasks to be executed, adding the target task to the tasks to be executed specifically includes:
[0027] When the computing tasks included in the second queue are all different from the target task, add the target task to the second queue.
[0028] Optionally, when the computing tasks included in the second queue are all different from the target task, adding the target task to the second queue specifically includes:
[0029] Determine the event function and calculation parameters corresponding to the target task according to the interaction operation of the user on the front-end page of the browser, where the calculation parameters are the input parameters of the event function;
[0030] When the event function and calculation parameters corresponding to the calculation task in the second queue are both different from the target task, use the target task as the task to be executed and add the target task to the second queue.
[0031] Optionally, the method further includes:
[0032] When the target task exists in the tasks to be executed, terminate the target task.
[0033] This specification provides a task scheduling device applied to a browser. The device includes:
[0034] A first deduplication module, in response to receiving a target task triggered by an interaction operation of a user on the front-end page of the browser, determines whether there is a calculation task in a waiting state that is the same as the target task within a set time;
[0035] A delay module, if not, sets the target task to a waiting state;
[0036] A second deduplication module, after the waiting state of the target task ends, adds the target task to the tasks to be executed when it is determined that there is no calculation task in the tasks to be executed that is the same as the target task. The tasks to be executed are calculation tasks that wait to be executed when the browser thread is idle.
[0037] This specification provides a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the above task scheduling method is implemented.
[0038] This specification provides an electronic device including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the above task scheduling method is implemented.
[0039] At least one of the above technical solutions adopted in this specification can achieve the following beneficial effects:
[0040] In the task scheduling method applied to a browser provided in this specification, in response to receiving a target task triggered by a user's interaction operation on the front-end page of the browser, it is determined whether there is a waiting computing task that is the same as the target task within a set time. If not, the target task is set to the waiting state. After the waiting state of the target task ends, when it is determined that there is no computing task that is the same as the target task among the tasks to be executed, the target task is added to the tasks to be executed, and the tasks to be executed are computing tasks that wait to be executed when the browser thread is idle.
[0041] With this method, setting a delay for the computing tasks initiated by the user can deduplicate the target tasks initiated by the user in real time and the computing tasks initiated by the user in the past that are in the waiting state. After the waiting state of the target task ends, a second deduplication is performed between the target task and the tasks to be executed that need to be executed when the thread is idle. When it is ensured that there are no duplicate tasks among the tasks to be executed, the target task is used as the computing task to be executed by the browser thread. Thus, through two deduplications, the execution of duplicate computing tasks is greatly reduced, the consumption of computing resources is reduced, and the performance of the browser is improved. Brief Description of the Drawings
[0042] The drawings described herein are used to provide a further understanding of this specification and form a part of this specification. The schematic embodiments of this specification and their descriptions are used to explain this specification and do not constitute an improper limitation to this specification. In the drawings:
[0043] Figure 1 It is a schematic flowchart of a task scheduling method in this specification;
[0044] Figure 2 It is an overall framework diagram of a task scheduling provided in this specification;
[0045] Figure 3 It is another overall framework diagram of a task scheduling provided in this specification;
[0046] Figure 4 It is a schematic diagram of a task scheduling device provided in this specification;
[0047] Figure 5 Corresponding to Figure 1 the schematic diagram of the electronic device. Detailed Embodiments
[0048] To make the objectives, technical solutions, and advantages of this specification clearer, the technical solutions of this specification will be clearly and completely described below in conjunction with specific embodiments of this specification and the corresponding drawings. Apparently, the described embodiments are only a part of the embodiments of this specification, rather than all the embodiments. Based on the embodiments in this specification, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the scope of protection of this application.
[0049] The following will detail the technical solutions provided by each embodiment of this specification in conjunction with the drawings.
[0050] Figure 1 It is a flowchart of a task scheduling method in this specification. This task scheduling method is applied to a browser and specifically includes the following steps:
[0051] S100: In response to receiving a target task triggered by a user's interaction operation on the front-end page of the browser, determine whether there is a waiting computing task identical to the target task within a set time.
[0052] All steps in the task scheduling method provided by this specification can be implemented by any electronic device with computing functions, such as terminals, servers, and other devices. For the sake of convenience in description, hereinafter, only the server is used as the execution entity to illustrate the task scheduling method provided by this specification. [[ID=I4]]
[0053] In the front-end page of the browser, user interaction operations such as clicks, scrolls, and inputs all correspond to corresponding event functions. When the user performs these operations, the computing tasks corresponding to the event functions are triggered. If the user frequently performs operations, the computing tasks are frequently triggered.
[0054] Generally, many computing tasks are complex. When the event functions of these complex computing tasks are frequently triggered, they consume a large amount of CPU resources, which will greatly reduce the web page performance. For example, when the user quickly adjusts the size of the browser window, the resize event will be continuously triggered. If no measures are taken, computing tasks such as the recomputing layout function and the page re-rendering function associated with the resize event will be frequently executed, resulting in browser lag.
[0055] In the method of this specification, the server responds to the user's interaction operation, determines the computing task triggered by the user, and will immediately use the computing task at the current moment as the target task to be scheduled.
[0056] The server sets a time delay for each computing task triggered by the user. The computing tasks before the time delay ends are in a waiting state.
[0057] If the user continuously performs the same interaction operation and frequently triggers a certain computing task, multiple identical computing tasks in a waiting state will be generated within a period of time. In other words, if there is a computing task identical to the target task among the computing tasks in the waiting state, it can be considered that a frequently triggered interaction operation has occurred. Based on this feature, the server performs the first deduplication on the target task according to the computing tasks in the waiting state.
[0058] The server queries whether there is a computing task identical to the target task among the computing tasks in the waiting state.
[0059] S102: If not, set the target task to the waiting state.
[0060] If there is no computing task identical to the target task among the computing tasks in the waiting state, it means that the user has not triggered the target task within the set time, and the server sets the target task to the waiting state.
[0061] Specifically, the server can set a timer for the target task according to a preset delay time. When the countdown of the delay time ends, the waiting state of the target task is lifted. The delay time can be set to any value as needed.
[0062] If there is a computing task identical to the target task among the computing tasks in the waiting state, it means that the target task has been repeatedly triggered within the set time, and the server terminates the target task.
[0063] In an example, the delay time can be set to 300ms. In the scenario where the user continuously and quickly scrolls the page, assuming the current moment is the 200th ms, and the computing task of the user's first page scroll is recorded as task B, with the timestamp of task B recorded as the zero moment, task B is set to a 300ms delay. At the current moment, the user continues to scroll the page, and the target task triggered by the page scroll at the current moment is recorded as task A. At the current moment, the delay of task B has not ended, and the server queries that the waiting task B and task A are identical computing tasks, so task A is terminated.
[0064] Especially, when the server determines that there is no computing task in the waiting state at the current moment, it can directly set the target task to the waiting state without performing the query operation among the computing tasks in the waiting state, thus accelerating the execution rate.
[0065] S104: After the waiting state of the target task ends, when it is determined that there is no computing task identical to the target task among the tasks to be executed, add the target task to the tasks to be executed, where the tasks to be executed are computing tasks that are executed when the browser thread is idle.
[0066] After the waiting state of the target task ends, the server performs a second deduplication operation on the target task according to the task to be executed, where the task to be executed is a computing task to be executed when the browser thread is idle.
[0067] Specifically, the server queries whether there is a computing task identical to the target task among the computing tasks to be executed. If there is, it indicates that the target task is a repeatedly triggered computing task, and the target task is terminated. If not, it indicates that the target task has not been triggered within a short period, and the target task is added to the tasks to be executed and waits for the browser thread to be idle to execute the target task.
[0068] For example, if the target task is task A, after the waiting state ends, the processing of task A continues. Query whether there is a task C identical to task A among the tasks to be executed. If there is, it indicates that task A is a duplicate task of task C, and task A is terminated. If not, task A is added to the tasks to be executed and waits for the browser thread to be idle to execute task A.
[0069] This method only executes computing tasks when the thread is idle, avoiding the accumulation of computing tasks caused by frequent triggering. At the same time, through the secondary deduplication operation of the tasks to be executed, it reduces the waste of computing resources by duplicate computing tasks and improves the fluency and stability of the browser.
[0070] Figure 2 This is an overall framework diagram of task scheduling provided in this specification. As Figure 2 shown, after triggering the target task according to the user's interaction operation, first query in the computing tasks in the waiting state and perform the first deduplication operation.
[0071] If there is a computing task identical to the target task in the computing tasks in the waiting state, the target task is terminated. If there is no computing task identical to the target task in the computing tasks in the waiting state, the target task is set to the waiting state. After the waiting state of the target task ends, query in the tasks to be executed and perform the second deduplication operation.
[0072] If there is a computing task identical to the target task in the tasks to be executed, the target task is terminated. If there is no computing task identical to the target task in the tasks to be executed, the target task is added to the tasks to be executed. Wait for the browser thread to be idle to execute the target task.
[0073] Based on the above Figure 1The described task scheduling method sets a delay for the calculation tasks initiated by the user. It can deduplicate the target tasks initiated by the user in real time and the calculation tasks initiated by the user in the past that are in the waiting state. After the waiting state of the target task ends, it performs a second deduplication on the target task and the tasks to be executed that need to be executed when the existing browser thread is idle. When it is ensured that there are no duplicate tasks among the tasks to be executed, the target task is used as the task to be executed by the browser thread. Thus, through two deduplications, the execution of duplicate calculation tasks is greatly reduced, the consumption of computing resources is reduced, and the performance of the browser is improved.
[0074] Through this method, it is possible to reduce the pressure on the limited computing resources of the browser caused by some intensive and repetitive tasks, and avoid the large occupation of the browser's computing resources by ineffective calculations. Specifically, performance can be improved in the following four aspects:
[0075] First, reduce the consumption of computing resources. In some scenarios with high-frequency triggers (such as when the user clicks a button to perform a certain type of complex calculation task), if not restricted, it may cause the function to be called frequently, thus occupying a large amount of CPU resources. For example, when the user quickly adjusts the size of the browser window, the resize event will be continuously triggered. If a complex function (such as recalculating the layout and re-rendering the page) is directly bound, it may cause the browser to freeze. Through the method provided by the present invention, these frequent calls can be "merged" into one call, greatly reducing the number of function executions, and thus reducing the burden on the CPU.
[0076] Second, provide smoother interaction. In some scenarios that require real-time feedback, such as dragging and scrolling, the present invention can avoid the lag and unsmoothness caused by frequently triggered calculation tasks. For example, when dragging an element, the browser thread is busy. By using the method provided by the present invention, it can be ensured that the execution frequency of other calculation tasks is reduced and they are only executed when the browser thread is idle, thus making the dragging process smoother.
[0077] Third, reduce the risk of browser crashes. In some extreme cases, such as when the user's rapid operations cause the function to be called frequently, it may cause the browser to crash or freeze. The present invention can reduce this risk by restricting the call frequency of the event function of the calculation task, thereby improving the stability and compatibility of the page.
[0078] Fourth, avoid misoperations. In some button click events, the user may accidentally click multiple times quickly. If not restricted, it may cause repeated form submissions, repeated triggering of certain operations, etc. Through the present invention, it can be ensured that multiple identical calculation task triggers by the user are merged into one, thus avoiding the adverse effects brought by user misoperations.
[0079] In one embodiment of this specification, the computing tasks in the waiting state in the above step S102 can be stored in a queue, which is hereinafter referred to as the first queue, that is, the computing tasks stored in the first queue are in the state of waiting for the end of the delay. According to the first-in, first-out characteristic of the queue, the earlier the triggered computing task, the more forward its storage position in the queue, and the earlier the triggered computing task, the earlier its waiting state is lifted and it enters the next scheduling stage.
[0080] The server can query in the first queue whether there is no computing task identical to the target task. If so, the server terminates the target task to prevent repeated invocation of the event function of the target task, resulting in waste of resources. If not, it means that the target task has not been repeatedly triggered within the set time. The server can set a delay time for the target task and add the target task to the first queue, waiting for the end of the delay time before performing the next processing on the target task.
[0081] In one embodiment of this specification, the delay time in the above step S102 can be set as a dynamic value to flexibly adapt to different interaction scenarios.
[0082] The server can determine the delay time corresponding to the target task in real time according to the trigger time interval between the target task and the previous computing task of the target task.
[0083] Specifically, the server can determine the trigger time interval between the target task and the previous computing task of the target task, and judge whether the trigger time interval is less than the preset interval. If so, on the basis of the delay time of the previous computing task, a specified time gradient value is added to obtain the delay time of the target task. If not, the delay time remains unchanged, that is, the delay time of the previous computing task is directly used as the delay time of the target task.
[0084] Through this embodiment, it is possible to set a relatively larger delay time for more frequent trigger operations to prevent browser thread blockage under high-frequency triggers.
[0085] In the above step S102, in order to make full use of computing resources and improve computing efficiency, the server can monitor the idle situation of the browser thread in real time.
[0086] When there are no other waiting computing tasks before the target task, and when the web page thread is monitored to be idle before the waiting state of the target task ends, the delay time of the target task is immediately cleared, the waiting state of the target task is ended, and the target task is added to the tasks to be executed.
[0087] In this embodiment, the browser thread is idle, indicating that there are no other tasks to be executed at the current moment. The target task is added after the tasks to be executed. The target task is the only computing task waiting to be executed among the tasks to be executed. At this time, the target task can be immediately executed.
[0088] In step S104 above, the server can also first determine whether there are tasks to be executed before querying among the tasks to be executed.
[0089] When it is determined that there are tasks to be executed, the operation described in step S104 above is performed to remove the computing tasks that are duplicate with the target task from the tasks to be executed. If there are no tasks to be executed at the current moment, the server can directly add the target task to the tasks to be executed.
[0090] That is, in this embodiment, when the tasks to be executed are empty, the query operation among the tasks to be executed can be omitted, and the target task can be directly added to the tasks to be executed, thereby improving the task scheduling efficiency.
[0091] In an embodiment of this specification, the tasks to be executed in step S104 above can be stored in the form of a queue, which is referred to as the second queue here.
[0092] Since the browser web page only supports single-thread tasks, the server will wait for the browser thread to be idle and store the computing tasks to be executed in the second queue in the order of triggering. When the thread is idle, each computing task can be executed in the order of storage of the computing tasks.
[0093] In this embodiment, for the server to determine whether there are tasks to be executed, specifically, it can be to determine whether the second queue is empty.
[0094] When the second queue is empty, it means that there are no computing tasks waiting to be executed when the browser thread is idle at the current moment, and the server adds the target task to the tasks to be executed.
[0095] When the second queue is not empty, it means that there is at least one computing task waiting to be executed when the browser thread is idle at the current moment. In this state, the server needs to ensure that there are no computing tasks in the tasks to be executed that are duplicate with the target task. Then the server queries in the second queue whether there is a computing task identical to the target task. If there is, the target task is terminated to avoid the repeated execution of the same computing task in a short time. If not, the target task is added to the tasks to be executed and joined the second queue, and waits for the browser thread to be idle to execute the target task.
[0096] Figure 3 For another overall framework diagram of task scheduling provided in this specification, in Figure 3In the illustrated embodiment, the computing tasks in the waiting state are stored in the first queue, and the tasks to be executed are stored in the second queue. The specific execution process is similar to that of Figure 2 the corresponding embodiment, and reference can be made to the description of the corresponding content above.
[0097] In an embodiment of the present specification, the basis for determining that computing tasks are the same is the called event function and the input parameters of the event function, that is, computing tasks with the same called event function and the same input parameters are determined to be the same computing tasks.
[0098] Then in step S102 above, the server queries whether there is a computing task in the computing tasks in the waiting state that is the same as the target task, and the following method can be specifically adopted.
[0099] The server responds to the interaction operation of the user on the browser front-end page, and determines the event function and computing parameters corresponding to the target task. The computing parameters are the input parameters of the computing function obtained according to the user's interaction operation. For example, if the user continuously scrolls the page to trigger a large number of position computing tasks, for the current scroll operation, the position where the page stops during scrolling is the input parameter of the position computing event function, that is, the computing parameter of the target task.
[0100] The server queries whether there is a computing task in the computing tasks in the waiting state that has the same event function and computing parameters as the target task.
[0101] Based on this embodiment, when the computing tasks in the waiting delay end state are stored in the first queue, the server can query in the first queue whether there is a computing task that has the same event function and computing parameters as the target task.
[0102] Similarly, in step S104 above, the server determines whether there is a computing task in the tasks to be executed that is the same as the target task. Specifically, it queries whether there is a computing task in the tasks to be executed that has the same event function and computing parameters as the target task.
[0103] Based on this embodiment, when the tasks to be executed are stored in the second queue, the server can query in the second queue whether there is a computing task that has the same event function and computing parameters as the target task.
[0104] In another embodiment of the present specification, the server can call a hash conversion function to determine the hash value of the computing task according to the event function and computing parameters of the computing task. The hash value is the unique identifier of each computing task. If the hash values of different computing tasks are the same, it means that these different computing tasks are actually the same computing tasks triggered repeatedly.
[0105] In the above steps S102 and S104, through the comparison of hash values, the query for the same computing task can be performed more quickly.
[0106] In an embodiment of the present specification, the computing tasks in the waiting state and the tasks to be executed can be stored in the same space, for example, stored in the same queue, which is hereinafter referred to as the third queue. Then, in this embodiment, the functions of the above first queue and second queue can be realized through the third queue.
[0107] In the third queue, there are two different states of computing tasks. Therefore, the computing tasks in this embodiment have a status identifier, which includes a waiting identifier and an executable identifier. The waiting identifier is used to mark the computing tasks in the waiting state, and the executable identifier is used to mark the computing tasks to be executed when the browser thread is idle. The present specification does not limit the specific forms of the waiting identifier and the executable identifier, as long as there are differences between the two status identifiers.
[0108] Then, in this embodiment, the above step S100 can be specifically as follows:
[0109] The server determines whether there is a computing task identical to the target task within a set time among the various computing tasks included in the third queue.
[0110] When there is no computing task identical to the target task among the computing tasks included in the third queue, the above steps S102 to S104 are executed.
[0111] In this embodiment, the server queries among the various computing tasks included in the third queue and executes the two query steps of the above steps S102 and S104 simultaneously, reducing the number of queries and improving the task scheduling efficiency.
[0112] In this embodiment, when the server determines that there is a duplicate task in the third queue, the duplicate task is a computing task identical to the target task. The server continues to determine the task status of the duplicate task according to the status identifier of the duplicate task.
[0113] If the duplicate task is in the waiting state, the server terminates the target task or overwrites the duplicate task with the target task.
[0114] If the duplicate task is in the executable state, calculate the trigger time interval according to the timestamp of the target task and the timestamp of the duplicate task. When the trigger time interval is less than the preset duplicate allowable duration, terminate the target task. When the trigger time interval is not less than the preset duplicate allowable duration, still regard the target task as a task to be executed and wait for the browser thread to be idle to execute the target task.
[0115] Because, when the trigger time interval is not less than the preset repetition allowable duration, it indicates that the trigger time interval between two identical computing tasks is relatively long. To accurately respond to the user's interaction operation, it is selected to allow the repeated execution of this computing task.
[0116] The above is the task scheduling method provided in this specification. Based on the same idea, this specification also provides a corresponding task scheduling device, as Figure 4 shown.
[0117] Figure 4 The figure is a schematic diagram of a task scheduling device provided in this specification. This device is applied to a browser and specifically includes:
[0118] The first duplicate removal module 200 is configured to, in response to receiving a target task triggered by a user's interaction operation on the front-end page of the browser, determine whether there is a computing task in a waiting state that is the same as the target task within a set time.
[0119] The delay module 202 is configured to, if not, set the target task to the waiting state.
[0120] The second duplicate removal module 204 is configured to, after the waiting state of the target task ends, add the target task to the tasks to be executed when it is determined that there is no computing task in the tasks to be executed that is the same as the target task. The tasks to be executed are computing tasks that wait for the browser thread to be idle for execution.
[0121] Optionally, the first duplicate removal module 200 is specifically configured to query in the first queue whether there is a computing task that is the same as the target task. The first queue stores computing tasks in a waiting state. The delay module 202 is specifically configured to, if not, add the target task to the first queue and set a delay time for the target task. If so, terminate the target task.
[0122] Optionally, the first duplicate removal module 200 is specifically configured to, according to the user's interaction operation on the front-end page of the browser, determine the event function and computing parameters corresponding to the target task. The computing parameters are the input parameters of the event function, and determine whether there is a computing task in the first queue whose corresponding event function and computing parameters are both the same as the target task.
[0123] Optionally, the second duplicate removal module 204 is specifically configured to determine whether there are tasks to be executed. When there are tasks to be executed, add the target task to the tasks to be executed when it is determined that there is no computing task in the tasks to be executed that is the same as the target task. When there are no tasks to be executed, add the target task to the tasks to be executed.
[0124] Optionally, the task to be executed is stored in the second queue. Specifically, when the computing tasks included in the second queue are all different from the target task, the second deduplication module 204 adds the target task to the second queue.
[0125] Optionally, the second deduplication module 204 is specifically configured to determine an event function and computing parameters corresponding to the target task according to the interaction operation of the user on the front-end page of the browser. The computing parameters are the input parameters of the event function. When the event function and computing parameters corresponding to the computing tasks in the second queue are all different from the target task, the target task is used as the task to be executed, and the target task is added to the second queue.
[0126] Optionally, when the target task exists in the tasks to be executed, the second deduplication module 204 terminates the target task.
[0127] This specification also provides a computer-readable storage medium storing a computer program that can be used to execute the above Figure 1 provided task scheduling method.
[0128] This specification also provides Figure 5 a schematic structural diagram of the electronic device shown. As Figure 5 described above, at the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory. Of course, it may also include other hardware required for other services. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to implement the above Figure 1 described task scheduling method. Of course, in addition to the software implementation method, this specification does not exclude other implementation methods, such as logical devices or a combination of software and hardware. That is, the execution subject of the following processing flow is not limited to each logical unit, but can also be hardware or logical devices.
[0129] The improvement of a technology can be clearly distinguished as either a hardware improvement (e.g., improvement of circuit structures such as diodes, transistors, switches, etc.) or a software improvement (improvement of method processes). However, with the development of technology, many improvements of method processes today can be regarded as direct improvements of hardware circuit structures. Almost all designers obtain the corresponding hardware circuit structure by programming the improved method process into the hardware circuit. Therefore, it cannot be said that an improvement of a method process cannot be implemented with a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. The designer can program by himself / herself to "integrate" a digital system on a single PLD, without having to ask a chip manufacturer to design and fabricate a dedicated integrated circuit chip. Moreover, nowadays, instead of manually fabricating integrated circuit chips, this programming is mostly implemented using "logic compiler" software, which is similar to the software compiler used in program development and writing. The original code before compilation also has to be written in a specific programming language, which is called a hardware description language (HDL), and there is not only one kind of HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones currently are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also be aware that by simply performing a little logical programming on the method process with the above-mentioned several hardware description languages and programming it into the integrated circuit, it is easy to obtain the hardware circuit that implements the logical method process.
[0130] The controller can be implemented in any suitable manner. For example, the controller can take the form of, for example, a microprocessor or a processor and a computer-readable medium storing computer-readable program code (such as software or firmware) executable by the (micro)processor, logic gates, switches, an application specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of the controller include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that, in addition to implementing the controller in the form of pure computer-readable program code, it is entirely possible to logically program the method steps to enable the controller to be implemented in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers, etc. to achieve the same function. Therefore, such a controller can be considered a hardware component, and the devices included therein for implementing various functions can also be regarded as the structures within the hardware component. Or even, the devices for implementing various functions can be regarded as either software modules for implementing the method or the structures within the hardware component.
[0131] The systems, devices, modules, or units illustrated in the above embodiments can be specifically implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer can be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or any combination of these devices.
[0132] For the convenience of description, when describing the above devices, they are described separately as various units according to their functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0133] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memories, CD-ROMs, optical memories, etc.) containing computer-usable program code.
[0134] This application is described with reference to the flowcharts and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram, and combinations of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing device to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing device produce means for implementing the functions specified in one Figure 1 flow or multiple flows and / or blocks Figure 1 block or multiple blocks.
[0135] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory produce a manufacture including instruction means that implement the functions specified in one Figure 1 flow or multiple flows and / or blocks Figure 1 block or multiple blocks.
[0136] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one Figure 1 flow or multiple flows and / or blocks Figure 1 block or multiple blocks.
[0137] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and memory.
[0138] The memory may include non-permanent memory in the form of computer-readable media, random access memory (RAM), and / or non-volatile memory such as read-only memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
[0139] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0140] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.
[0141] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems, or computer program products. Therefore, this specification may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0142] This specification may be described in the general context of computer-executable instructions, such as program modules, executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform specific tasks or implement specific abstract data types. This specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media, including storage devices.
[0143] The various embodiments in this specification are described in a progressive manner. For the same or similar parts among the various embodiments, reference can be made to each other, and each embodiment focuses on the differences from other embodiments. In particular, for system embodiments, since they are basically similar to method embodiments, the description is relatively simple, and for related parts, reference can be made to the partial description of method embodiments.
[0144] The above description is only for the embodiments of this specification and is not intended to limit this specification. For those skilled in the art, various changes and modifications can be made to this specification. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this specification shall be included within the scope of the claims of this application.
Claims
1. A task scheduling method, characterized in that, Applied to a browser, including: In response to a target task triggered by a user's interaction operation on the front-end page of the browser, determining whether there is a computing task in a waiting state that is the same as the target task within a set time; If not, setting the target task to a waiting state, determining the trigger time interval between the target task and the previous computing task, and judging whether the trigger time interval is less than a preset interval; if so, on the basis of the delay time of the previous computing task, adding a specified time gradient value to obtain the delay time of the target task; if not, using the delay time of the previous computing task as the delay time of the target task; After the waiting state of the target task ends, when it is determined that there is no computing task in the to-be-executed tasks that is the same as the target task, adding the target task to the to-be-executed tasks, where the to-be-executed tasks are computing tasks that wait to be executed when the browser thread is idle.
2. The method according to claim 1, wherein Determining whether there is a computing task in a waiting state that is the same as the target task within a set time includes: In a first queue, querying whether there is a computing task that is the same as the target task, where the first queue stores computing tasks in a waiting state; If not, setting the target task to a waiting state, specifically including: If not, adding the target task to the first queue and setting a delay time for the target task; The method further includes: If so, terminating the target task.
3. The method according to claim 2, wherein Querying whether there is a computing task that is the same as the target task specifically includes: According to the user's interaction operation on the front-end page of the browser, determining the event function and computing parameters corresponding to the target task, where the computing parameters are the input parameters of the event function; Judging whether there is a computing task in the first queue whose corresponding event function and computing parameters are both the same as those of the target task.
4. The method according to claim 1, wherein Before adding the target task to the to-be-executed tasks when it is determined that there is no computing task in the to-be-executed tasks that is the same as the target task, the method further includes: Judging whether there are to-be-executed tasks; When adding the target task to the to-be-executed tasks when it is determined that there is no computing task in the to-be-executed tasks that is the same as the target task, specifically including: When there are the to-be-executed tasks, when it is determined that there is no computing task in the to-be-executed tasks that is the same as the target task, adding the target task to the to-be-executed tasks; When there are no the to-be-executed tasks, adding the target task to the to-be-executed tasks.
5. The method according to claim 4, wherein The to-be-executed tasks are stored in a second queue; When adding the target task to the to-be-executed tasks when it is determined that there is no computing task in the to-be-executed tasks that is the same as the target task, specifically including: When the computing tasks included in the second queue are all different from the target task, adding the target task to the second queue.
6. The method according to claim 5, wherein When the computing tasks included in the second queue are all different from the target task, adding the target task to the second queue, specifically including: Determine the event function and calculation parameters corresponding to the target task according to the interaction operation of the user on the front-end page of the browser, where the calculation parameters are the input parameters of the event function. When the event function and calculation parameters corresponding to the calculation task in the second queue are both different from the target task, use the target task as the task to be executed and add the target task to the second queue.
7. The method according to claim 1, wherein The method further includes: When the target task exists in the tasks to be executed, terminate the target task.
8. A task scheduling device, characterized in that, Applied to a browser, it includes: A first deduplication module that, in response to a target task triggered by an interaction operation of the user on the front-end page of the browser, determines whether there is a waiting calculation task identical to the target task within a set time. A delay module. If not, set the target task to the waiting state, determine the trigger time interval between the target task and the previous calculation task, and determine whether the trigger time interval is less than a preset interval. If so, on the basis of the delay time of the previous calculation task, increase it by a specified time gradient value to obtain the delay time of the target task. If not, use the delay time of the previous calculation task as the delay time of the target task. A second deduplication module. After the waiting state of the target task ends, when it is determined that there is no calculation task identical to the target task in the tasks to be executed, add the target task to the tasks to be executed, where the tasks to be executed are calculation tasks that wait for the browser thread to be idle for execution.
9. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, and when the computer program is executed by a processor, the method described in any one of claims 1 to 7 above is implemented.
10. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the program, the method described in any one of claims 1 to 7 above is implemented.
Citation Information
Patent Citations
Event processing method and device, computer equipment, readable storage medium and program product
CN119179584A