Page scheduling method and apparatus, electronic device, and storage medium

CN115686781BActive Publication Date: 2026-10-16BEIJING DIPU TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202211276067.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-18
Publication Date
2026-10-16
Estimated Expiration
2042-10-18

AI Technical Summary

Technical Problem

[0005]本申请的主要目的在于提供一种页面调度方法以及装置、电子设备、存储介质,以解决前端页面无法实现灵活调度的问题

Benefits of technology

[0028] In this embodiment, the scheduling task is submitted to the dispatcher, and the dispatcher converts the scheduling task into a scheduling job. This achieves the goal of the dispatcher periodically obtaining the scheduling job from the scheduling queue and implementing the corresponding scheduling function according to the preset scheduling strategy. This achieves the technical effect of adjustable scheduling on the front end, and solves the technical problem of page unresponsiveness caused by long function execution time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115686781B_ABST
    Figure CN115686781B_ABST
Patent Text Reader

Abstract

The application discloses a page scheduling method and device, electronic equipment and storage medium. The method comprises the following steps: submitting a scheduling task to a distributor, wherein the scheduling task is edited by a user through a preset API; converting the scheduling task into a scheduling job via the distributor, wherein the scheduling job comprises a plurality of schedulable function units, and the scheduling job is put into a scheduling queue; periodically acquiring the scheduling job from the scheduling queue by a scheduler, and realizing corresponding scheduling functions according to a preset scheduling strategy. The application solves the technical problem that a front-end page cannot realize flexible scheduling. The application realizes flexible scheduling of the front-end page.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of front-end development, and more specifically, to a page scheduling method, device, electronic device, and storage medium. Background Technology

[0002] In traditional front-end development, when the logic of a function is complex, it may cause the entire front-end page to stop responding.

[0003] In related technologies, JavaScript provides an asynchronous task scheduling mechanism based on Promise. However, the scheduler of the native Promise mechanism provided by JavaScript can only be based on the FIFO strategy, which cannot meet the needs of some scenarios that require flexible scheduling strategies.

[0004] There is currently no effective solution to the problem that front-end pages cannot be flexibly scheduled in related technologies. Summary of the Invention

[0005] The main objective of this application is to provide a page scheduling method, device, electronic device, and storage medium to solve the problem that front-end pages cannot be flexibly scheduled.

[0006] To achieve the above objectives, according to one aspect of this application, a page scheduling method is provided, which is applied to a front-end client.

[0007] The page scheduling method according to this application includes: submitting a scheduling task to a dispatcher, wherein the scheduling task is obtained by the user through a preset API;

[0008] The dispatcher converts the scheduling task into a scheduling job, wherein the scheduling job includes multiple schedulable function units and the scheduling job is placed in a scheduling queue.

[0009] The scheduler periodically retrieves the scheduled jobs from the scheduling queue and implements the corresponding scheduling functions according to the preset scheduling strategy.

[0010] In some embodiments, the method is used to pre-set scenarios where page becomes unresponsive due to long function execution times.

[0011] In some embodiments, implementing the corresponding scheduling function according to a preset scheduling strategy includes:

[0012] In the scenario where the page stops responding, when the user needs to be responded to first, the corresponding scheduling function is implemented according to the preset scheduling strategy LIFO, where LIFO stands for Last In First Out.

[0013] In the scenario where the page stops responding, when the user needs a priority and urgent response to the user's request, the corresponding scheduling function is implemented according to the preset scheduling strategy PL, where PL is the priority strategy.

[0014] In some embodiments, implementing the corresponding scheduling function according to a preset scheduling strategy includes:

[0015] In the scenario where the page stops responding, when the user cannot confirm which priority to use to respond to the user's request, the corresponding scheduling function is implemented according to the preset scheduling strategy OPF, where OPF is the optimization priority strategy.

[0016] In some embodiments, the step of converting the scheduling task into a scheduling job via the dispatcher, wherein the scheduling job includes a plurality of schedulable function units, and the scheduling job is placed in a scheduling queue, includes:

[0017] The dispatcher iterates through the scheduled tasks, converts them into schedulable function units, and establishes a set of scheduled jobs for use as the schedulable function units. Scheduling is achieved by switching between different scheduled jobs.

[0018] In some embodiments, the scheduling function unit is used as the smallest unit and has atomicity.

[0019] In some embodiments, submitting the scheduling task to the dispatcher, wherein the scheduling task is obtained by the user through a preset API, includes:

[0020] By using a preset static function, users can submit the scheduled task to the scheduler.

[0021] To achieve the above objectives, according to another aspect of this application, a page scheduling device is provided, which is applied to a front-end client.

[0022] The page scheduling device according to this application includes:

[0023] The submission module is used to submit the scheduled task to the dispatcher, wherein the scheduled task is obtained by the user through a preset API.

[0024] A conversion module is used to convert the scheduling task into a scheduling job via the dispatcher, wherein the scheduling job includes multiple schedulable function units and the scheduling job is placed in a scheduling queue.

[0025] The acquisition module is used to periodically acquire the scheduled job from the scheduling queue through the scheduler and implement the corresponding scheduling function according to the preset scheduling strategy.

[0026] To achieve the above objectives, according to another aspect of this application, embodiments of this application also provide an electronic device, including: a processor; and a memory arranged to store computer-executable instructions, which, when executed, cause the processor to perform any of the methods described above.

[0027] To achieve the above objectives, according to another aspect of this application, embodiments of this application also provide a computer-readable storage medium that stores one or more programs, which, when executed by an electronic device including multiple applications, cause the electronic device to perform any of the methods described above.

[0028] In this embodiment, the scheduling task is submitted to the dispatcher, and the dispatcher converts the scheduling task into a scheduling job. This achieves the goal of the dispatcher periodically obtaining the scheduling job from the scheduling queue and implementing the corresponding scheduling function according to the preset scheduling strategy. This achieves the technical effect of adjustable scheduling on the front end, and solves the technical problem of page unresponsiveness caused by long function execution time. Attached Figure Description

[0029] The accompanying drawings, which form part of this application, are used to provide a further understanding of the application and to make other features, objects, and advantages of the application more apparent. The illustrative embodiments and descriptions of this application are used to explain the application and do not constitute an undue limitation of the application. In the drawings:

[0030] Figure 1 This is a schematic diagram of the scheduling framework structure of the page scheduling method according to an embodiment of this application;

[0031] Figure 2 This is a flowchart illustrating a page scheduling method according to an embodiment of this application;

[0032] Figure 3 This is a schematic diagram of the structure of a page scheduling device according to an embodiment of this application. Detailed Implementation

[0033] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0034] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate for the embodiments of this application described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0035] In this application, the terms "upper," "lower," "left," "right," "front," "rear," "top," "bottom," "inner," "outer," "middle," "vertical," "horizontal," "lateral," and "longitudinal" indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. These terms are primarily for the purpose of better describing this application and its embodiments, and are not intended to limit the indicated device, element, or component to having a specific orientation, or to be constructed and operated in a specific orientation.

[0036] Furthermore, in addition to indicating location or positional relationship, some of the aforementioned terms may also have other meanings. For example, the term "above" may also be used in some cases to indicate a certain dependency or connection relationship. Those skilled in the art can understand the specific meaning of these terms in this application based on the specific circumstances.

[0037] Furthermore, the terms "installation," "setup," "equipped with," "connection," "linking," and "socketing" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral structure; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium, or an internal connection between two devices, components, or parts. Those skilled in the art can understand the specific meaning of these terms in this application based on the specific circumstances.

[0038] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.

[0039] like Figure 1The diagram shows the hardware structure of the scheduling framework for the page scheduling method according to an embodiment of this application. The overall architecture of the scheduling framework consists of three parts: a dispatcher, a scheduling queue, and a scheduler. The dispatcher is responsible for submitting jobs to the scheduling queue after responding to events, for the scheduler to execute. The scheduler uses a time-slice algorithm to periodically retrieve tasks from the scheduling queue at a fixed frequency and performs scheduling according to its own scheduling algorithm. Different scheduling strategies can be selected by adjusting the scheduler parameters to achieve different scheduling functions. In addition, the scheduling framework subdivides scheduling into three granularities: task, job, and scheduled function unit (SFU). The framework achieves scheduling through operations on these three objects.

[0040] A Task is a programmatic task created by the user according to the API provided by the framework. Tasks are compatible with JavaScript's native Promise syntax and can be easily converted from native JavaScript Promises to Tasks for more flexible scheduling capabilities.

[0041] Specifically, the Task is constructed as follows:

[0042] let task=new Task(start_up).then(fun_a).then(……).catch(fun_err).finally(fun_finally)

[0043] Then() can be chained infinitely to create new then() calls, thus achieving chained calls.

[0044] The meanings of the bold italicized characters are shown in the table below:

[0045]

[0046]

[0047] A Job is a collection of SFUs (Skill Functions). The dispatcher iterates through Tasks, converting tasks within Tasks into SFUs, which then constitute the entire Job. The Job is the fundamental object for scheduling by the scheduling framework in this embodiment. This scheduling framework does not switch between different SFUs within the same Job, but rather switches between different Jobs to achieve scheduling. This scheduling framework guarantees that SFUs within the same Job are executed in the order they were submitted by the user, avoiding out-of-order execution.

[0048] SFU, Scheduled Function Unit, is the smallest unit of scheduling in this scheduling framework and is atomic. The scheduling framework in this application guarantees that a single SFU is atomic, meaning that an SFU either does not execute or completes its execution and will not be in an intermediate state.

[0049] like Figure 2 As shown, the method includes the following steps S210 to S230:

[0050] Step S210: Submit the scheduling task to the dispatcher, wherein the scheduling task is obtained by the user through a preset API.

[0051] Since the scheduled tasks are obtained by users through a preset API, the scheduled tasks (Tasks) obtained through API editing first need to be submitted to the dispatcher. It can be understood that the dispatcher is used to distribute the scheduled tasks.

[0052] Step S220: The scheduling task is converted into a scheduling job via the dispatcher, wherein the scheduling job includes multiple schedulable function units and the scheduling job is placed in a scheduling queue.

[0053] The dispatcher converts the scheduled task into a scheduled job, and it is understood that the scheduled job may include multiple schedulable function units (SFUs).

[0054] In some embodiments, the collection of the plurality of schedulable function units (SFUs) constitutes a job. Furthermore, since each individual SFU is atomic, it either does not execute or completes execution; it cannot remain in an intermediate state. Additionally, the scheduled job is placed into a scheduling queue in the form of these SFUs.

[0055] Preferably, the scheduling function unit is used as the smallest unit and has atomicity.

[0056] In some embodiments, the scheduler uses a time-slice algorithm to periodically retrieve scheduled jobs from the scheduling queue at a fixed frequency and performs scheduling according to its own scheduling algorithm. Different scheduling functions can be achieved by adjusting the scheduler parameters to select different scheduling strategies.

[0057] Step S230: The scheduler periodically retrieves the scheduled job from the scheduling queue and implements the corresponding scheduling function according to the preset scheduling strategy.

[0058] The scheduler periodically retrieves the scheduled jobs from the scheduling queue and can also implement the corresponding scheduling functions according to a preset scheduling strategy.

[0059] In some embodiments, the built-in scheduling strategies include FIFO, First-In-First-Out, and the scheduling strategy of JavaScript's native Promise. Users are not advised to choose this scheduling strategy.

[0060] In some embodiments, the built-in scheduling strategy includes LIFO (Last In First Out), which achieves the shortest response time. The scheduler always selects the newest task for execution, ensuring that user operations receive the most timely response. However, this may result in older tasks never getting an execution opportunity and thus becoming unresponsive.

[0061] In some embodiments, the built-in scheduling policies include Priority FIFO / LIFO (PF / PL), a priority strategy. Using this strategy requires setting a priority for the task; the default priority is 5. When using this strategy, the scheduler prioritizes tasks with higher priorities. When task priorities are the same, it degenerates into a first-in-first-out (FIFO) or last-in-first-out (LIFO) strategy.

[0062] Users can choose this strategy: when an important task needs to be prioritized, the user simply raises the task's priority. This is a preemptive scheduling strategy, meaning that a high-priority task can interrupt an currently executing task to gain priority.

[0063] In some embodiments, the built-in scheduling policy includes Optimized Priority FIFO (OPF), which is the default scheduling policy in this scheduling framework. This policy is an optimization based on PF. When using this policy, the scheduler prioritizes the execution of tasks with higher priorities. When tasks have the same priority, the scheduler will round-robin among all tasks of the same priority to ensure that no task becomes unresponsive. If a new high-priority task joins during the round-robin process, the new high-priority task will also preempt the scheduler.

[0064] It's important to note that OPF is also a preemptive scheduler. It employs a round-robin algorithm to implement a moderate scheduling strategy, preventing tasks from becoming unresponsive (unresponsive) and also avoiding achieving the shortest response time. Therefore, it is the default scheduler in this scheduling framework.

[0065] As can be seen from the above description, this application achieves the following technical effects:

[0066] By submitting scheduling tasks to a dispatcher, which then converts the tasks into scheduling jobs, the scheduling system periodically retrieves these jobs from the scheduling queue and implements the corresponding scheduling functions according to a preset scheduling strategy. This achieves the technical effect of adjustable scheduling on the front end, thereby solving the technical problem of page unresponsiveness caused by long function execution times.

[0067] As a preferred embodiment, the method is used for scenarios where the page stops responding due to long function execution time.

[0068] Unlike related technologies, JavaScript's native Promise mechanism scheduler can only operate on a FIFO (First-In, First-Out) basis, which cannot meet the needs of scenarios requiring flexible scheduling strategies. The method in this application embodiment utilizes this framework to address scenarios where page unresponsiveness is caused by long function execution times.

[0069] In a preferred embodiment, the step of implementing the corresponding scheduling function according to the preset scheduling strategy includes: for the scenario where the page stops responding, when the user needs to respond to the user request first, implementing the corresponding scheduling function according to the preset scheduling strategy LIFO, where LIFO is Last In First Out; for the scenario where the page stops responding, when the user needs to respond to the user request first and urgently, implementing the corresponding scheduling function according to the preset scheduling strategy PL, where PL is a priority strategy.

[0070] In practice, LIFO is selected when the user needs the fastest response to the user's request. In other words, selecting this scheduling strategy can obtain the shortest response time. The scheduler will always select the latest task to execute, which can ensure that the user's operation can receive the most timely response.

[0071] Furthermore, the priority strategy (PL) is selected when user requests are responded to as quickly as possible, while also being able to handle sudden, urgent needs. In other words, a priority strategy is employed, requiring tasks to be assigned a priority level; the default priority is 5. When using this strategy, the scheduler prioritizes tasks with higher priorities. If task priorities are the same, the strategy degenerates into a first-in-first-out (FIFO) or last-in-first-out (LIFO) strategy.

[0072] As a preferred embodiment, the step of implementing the corresponding scheduling function according to the preset scheduling strategy includes: in the scenario where the page stops responding, when the user cannot confirm which priority to use to respond to the user request, implementing the corresponding scheduling function according to the preset scheduling strategy OPF, wherein OPF is an optimization priority strategy.

[0073] In practical implementation, when users are unsure of the scenario they are facing and need a moderate scheduler that won't cause problems, OPF (Optimization Priority) is chosen. In other words, an optimization-first strategy is adopted, which is the default scheduling strategy in this framework. This strategy is an optimization based on PF. When using this strategy, the scheduler prioritizes the execution of higher-priority tasks. When tasks have the same priority, the scheduler will round-robin among all tasks of the same priority to ensure that no task becomes unresponsive. If a new higher-priority task joins during the round-robin process, the new higher-priority task will also preempt the scheduler.

[0074] In a preferred embodiment, the step of converting the scheduling task into a scheduling job via the dispatcher, wherein the scheduling job includes multiple schedulable function units and the scheduling job is placed in a scheduling queue, includes: traversing the scheduling task via the dispatcher, converting the scheduling task into a schedulable function unit, and establishing a scheduling job as a set of the schedulable function units, and realizing scheduling by switching between different scheduling jobs.

[0075] In practice, a Job is a collection of SFUs (Skill Functions). The dispatcher iterates through Tasks, converting tasks within Tasks into SFUs, which then form the entire Job. The Job is the fundamental object for scheduling within this framework. This framework does not switch between different SFUs within the same Job; instead, it switches between different Jobs to achieve scheduling. This framework guarantees that SFUs within the same Job are executed in the order they were submitted by the user, avoiding out-of-order execution.

[0076] In a preferred embodiment, submitting the scheduling task to the dispatcher, wherein the scheduling task is obtained by the user through a preset API, includes: using a preset static function to enable the user to submit the scheduling task to the dispatcher.

[0077] In practice, the scheduling process mainly includes submission, which is triggered by the user, who actively submits the Task to the scheduler.

[0078] Specifically, the scheduling framework in this application provides a static function for users to submit tasks. The usage method is as follows:

[0079] Scheduler[.strategy(FIFO / LIFO / PF / PL / OPF)].submit(task);

[0080] The `.strategy` option is used to set the scheduling strategy. It is optional and defaults to OPF.

[0081] The scheduling process also includes transformation, which mainly converts Tasks into Tasks composed of SFUs according to rules. The principle of transformation is that each functional unit in the Task is converted into an SFU.

[0082] The scheduling process includes scheduling. In this embodiment, the scheduling framework periodically calls the doSchedule function of the scheduling strategy. Different scheduling strategies can be implemented simply by implementing different doSchedule functions.

[0083] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.

[0084] According to an embodiment of this application, a page scheduling device for implementing the above method is also provided, applied to a front-end client, such as... Figure 3 As shown, the device 300 includes:

[0085] Submission module 310 is used to submit a scheduling task to the dispatcher, wherein the scheduling task is obtained by the user through a preset API.

[0086] Conversion module 320 is used to convert the scheduling task into a scheduling job via the dispatcher, wherein the scheduling job includes multiple schedulable function units and the scheduling job is placed in a scheduling queue;

[0087] The acquisition module 330 is used to periodically acquire the scheduled job from the scheduling queue through the scheduler and implement the corresponding scheduling function according to the preset scheduling strategy.

[0088] In the submission module 310 of this application embodiment, since the scheduling task is obtained by the user through a preset API, the scheduling task (Task) obtained through API editing first needs to be submitted to the dispatcher. It can be understood that the dispatcher is used to distribute scheduling tasks.

[0089] In the conversion module 320 of this application embodiment, the scheduling task is converted into a scheduling job via the dispatcher. It can be understood that the scheduling job may include multiple schedulable function units (SFUs).

[0090] In some embodiments, the collection of the plurality of schedulable function units (SFUs) constitutes a job. Furthermore, since each individual SFU is atomic, it either does not execute or completes execution; it cannot remain in an intermediate state. Additionally, the scheduled job is placed into a scheduling queue in the form of these SFUs.

[0091] Preferably, the scheduling function unit is used as the smallest unit and has atomicity.

[0092] In some embodiments, the scheduler uses a time-slice algorithm to periodically retrieve scheduled jobs from the scheduling queue at a fixed frequency and performs scheduling according to its own scheduling algorithm. Different scheduling functions can be achieved by adjusting the scheduler parameters to select different scheduling strategies.

[0093] In the acquisition module 330 of this application embodiment, the scheduler periodically acquires the scheduled job from the scheduling queue, and can also implement the corresponding scheduling function according to the preset scheduling strategy.

[0094] In some embodiments, the built-in scheduling strategies include FIFO, First-In-First-Out, and the scheduling strategy of JavaScript's native Promise. Users are not advised to choose this scheduling strategy.

[0095] In some embodiments, the built-in scheduling strategy includes LIFO (Last In First Out), which achieves the shortest response time. The scheduler always selects the newest task for execution, ensuring that user operations receive the most timely response. However, this may result in older tasks never getting an execution opportunity and thus becoming unresponsive.

[0096] In some embodiments, the built-in scheduling policies include Priority FIFO / LIFO (PF / PL), a priority strategy. Using this strategy requires setting a priority for the task; the default priority is 5. When using this strategy, the scheduler prioritizes tasks with higher priorities. When task priorities are the same, it degenerates into a first-in-first-out (FIFO) or last-in-first-out (LIFO) strategy.

[0097] Users can choose this strategy: when an important task needs to be prioritized, the user simply raises the task's priority. This is a preemptive scheduling strategy, meaning that a high-priority task can interrupt an currently executing task to gain priority.

[0098] In some embodiments, the built-in scheduling policy includes Optimized Priority FIFO (OPF), which is the default scheduling policy in this scheduling framework. This policy is an optimization based on PF. When using this policy, the scheduler prioritizes the execution of tasks with higher priorities. When tasks have the same priority, the scheduler will round-robin among all tasks of the same priority to ensure that no task becomes unresponsive. If a new high-priority task joins during the round-robin process, the new high-priority task will also preempt the scheduler.

[0099] It's important to note that OPF is also a preemptive scheduler. It employs a round-robin algorithm to implement a moderate scheduling strategy, preventing tasks from becoming unresponsive (unresponsive) and also avoiding achieving the shortest response time. Therefore, it is the default scheduler in this scheduling framework.

[0100] Obviously, those skilled in the art should understand that the modules or steps of this application described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using computer-executable program code, thereby storing them in a storage device for execution by a computing device, or fabricating them separately as individual integrated circuit modules, or fabricating multiple modules or steps as a single integrated circuit module. Thus, this application is not limited to any particular combination of hardware and software.

[0101] This application also provides a front-end scheduling framework based on schedulable function units (SFUs), which serves as the scheduling entity. This framework subdivides scheduling into three granularities: Task, Job, and Scheduled Function Unit (SFU). The framework achieves scheduling through operations on these three objects.

[0102] in,

[0103] Tasks are tasks programmed by users according to the APIs provided by the framework. Tasks are compatible with JavaScript's native Promise syntax, and native JavaScript Promises can be easily converted into Tasks for more flexible scheduling capabilities.

[0104] The Task is constructed in the following form:

[0105] let task=new Task(start_up).then(fun_a).then(……).catch(fun_err).finally(fun_finally)

[0106] Then() can be chained infinitely to create new then() calls, thus achieving chained calls.

[0107] A Job is a collection of SFUs (Skill Functions). The dispatcher iterates through Tasks, converting tasks within Tasks into SFUs, which then form the entire Job. The Job is the fundamental object for scheduling within this framework. This framework does not switch between different SFUs within the same Job; instead, it switches between different Jobs to achieve scheduling. This framework guarantees that SFUs within the same Job are executed in the order they were submitted by the user, avoiding out-of-order execution.

[0108] SFU, Scheduled Function Unit, is the smallest unit of scheduling in this scheduling framework and is atomic. This scheduling framework guarantees that a single SFU is atomic, meaning that an SFU either does not execute or completes its execution; it will not be in an intermediate state.

[0109] The scheduling process includes the following:

[0110] (1) Submit

[0111] The submission process is triggered by the user, who actively submits the Task to the scheduler.

[0112] This scheduling framework provides a static function for users to submit tasks. The usage is as follows:

[0113] Scheduler[.strategy(FIFO / LIFO / PF / PL / OPF)].submit(task);

[0114] The `.strategy` option is used to set the scheduling strategy. It is optional and defaults to OPF.

[0115] (2) Conversion

[0116] The conversion process mainly transforms a Task into a Task composed of SFUs according to certain rules. The principle of the conversion is that each function unit in the Task is converted into an SFU.

[0117] (3) Scheduling

[0118] This scheduling framework periodically calls the doSchedule function of the scheduling strategy. Different scheduling strategies can be implemented simply by implementing different doSchedule functions.

[0119] (4) Built-in scheduling strategy

[0120] FIFO (First In, First Out) is the native Promise scheduling strategy in JavaScript. It is not recommended that users choose this scheduling strategy.

[0121] LIFO (Last In, First Out) scheduling strategy achieves the shortest response time, as the scheduler always selects the newest task for execution, ensuring timely responses to user actions. However, this can potentially cause older tasks to remain unexecuted and unable to respond.

[0122] Priority FIFO / LIFO (PF / PL) is a priority strategy. Using this strategy requires setting a priority for the task; the default priority is 5. When using this strategy, the scheduler will prioritize tasks with higher priorities. When task priorities are the same, it degenerates into a first-in-first-out (FIFO) or last-in-first-out (LIFO) strategy.

[0123] Users can choose this strategy: when an important task needs to be prioritized, the user simply raises the task's priority. This is a preemptive scheduling strategy, meaning that a high-priority task can interrupt an currently executing task to gain priority.

[0124] Optimized Priority FIFO (OPF) is the default scheduling strategy in this framework. It's an optimization of PF. When using this strategy, the scheduler prioritizes tasks with higher priorities. When tasks have the same priority, the scheduler will round-robin among all tasks of the same priority to ensure no task becomes unresponsive. If a new high-priority task joins during the round-robin process, it will also preempt the scheduler.

[0125] OPF is also a preemptive scheduler that implements a moderate scheduling strategy through a round-robin algorithm. It avoids situations where tasks become unresponsive, but also avoids achieving the shortest response time. Therefore, it is the default scheduler in this scheduling framework.

[0126] Embodiments of this application also provide a storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above method embodiments when running.

[0127] Optionally, in this embodiment, the storage medium may be configured to store a computer program for performing the following steps:

[0128] S1, Submit the scheduling task to the dispatcher, wherein the scheduling task is obtained by the user through a preset API;

[0129] S2, the scheduling task is converted into a scheduling job via the dispatcher, wherein the scheduling job includes multiple schedulable function units and the scheduling job is placed in a scheduling queue;

[0130] S3, the scheduler periodically retrieves the scheduled jobs from the scheduling queue and implements the corresponding scheduling function according to the preset scheduling strategy.

[0131] Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing computer programs, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.

[0132] Embodiments of this application also provide an electronic device including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.

[0133] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.

[0134] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:

[0135] S1, Submit the scheduling task to the dispatcher, wherein the scheduling task is obtained by the user through a preset API;

[0136] S2, the scheduling task is converted into a scheduling job via the dispatcher, wherein the scheduling job includes multiple schedulable function units and the scheduling job is placed in a scheduling queue;

[0137] S3, the scheduler periodically retrieves the scheduled jobs from the scheduling queue and implements the corresponding scheduling function according to the preset scheduling strategy.

[0138] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementations, and will not be repeated here.

[0139] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.

Claims

1. A page scheduling method, characterized in that, Applied to a front-end client, the method includes: The scheduled task is submitted to the dispatcher, wherein the scheduled task is obtained by the user through a preset API; the scheduled task is compatible with the native JavaScript Promise syntax, and the native JavaScript Promise is converted into a scheduled task. The dispatcher converts the scheduling task into a scheduling job, wherein the scheduling job includes multiple schedulable function units and the scheduling job is placed in a scheduling queue. The scheduler periodically retrieves the scheduled jobs from the scheduling queue and implements the corresponding scheduling functions according to the preset scheduling strategy. The process of converting the scheduling task into a scheduling job via the dispatcher, wherein the scheduling job includes multiple schedulable function units, and the scheduling job is placed in a scheduling queue, includes: The dispatcher iterates through the scheduled tasks, converts them into schedulable function units, and establishes a set of scheduled jobs for use as the schedulable function units. Scheduling is achieved by switching between different scheduled jobs.

2. The method according to claim 1, characterized in that, This is used for scenarios where the page becomes unresponsive due to a long execution time of a preset function.

3. The method according to claim 2, characterized in that, The step of implementing the corresponding scheduling function according to the preset scheduling strategy includes: In the scenario where the page stops responding, when the user needs to be responded to first, the corresponding scheduling function is implemented according to the preset scheduling strategy LIFO, where LIFO stands for Last In First Out. In the scenario where the page stops responding, when the user needs a priority and urgent response to the user's request, the corresponding scheduling function is implemented according to the preset scheduling strategy PL, where PL is the priority strategy.

4. The method according to claim 2, characterized in that, The step of implementing the corresponding scheduling function according to the preset scheduling strategy includes: In the scenario where the page stops responding, when the user cannot confirm which priority to use to respond to the user's request, the corresponding scheduling function is implemented according to the preset scheduling strategy OPF, where OPF is the optimization priority strategy.

5. The method according to claim 1, characterized in that, The scheduling function unit is used as the smallest unit and has atomicity.

6. The method according to claim 1, characterized in that, The step of submitting the scheduling task to the dispatcher, wherein the scheduling task is obtained by the user through a preset API, includes: By using a preset static function, users can submit the scheduled task to the scheduler.

7. A page scheduling device, characterized in that, Applied to a front-end client, the device includes: The submission module is used to submit scheduled tasks to the dispatcher, wherein the scheduled tasks are obtained by the user through a preset API; the scheduled tasks are compatible with JavaScript's native Promise syntax, converting native JavaScript Promises into scheduled tasks; A conversion module is used to convert the scheduling task into a scheduling job via the dispatcher, wherein the scheduling job includes multiple schedulable function units and the scheduling job is placed in a scheduling queue. An acquisition module is used to periodically acquire the scheduled job from the scheduling queue through a scheduler and implement the corresponding scheduling function according to a preset scheduling strategy; the step of converting the scheduling task into a scheduled job via the dispatcher, wherein the scheduled job includes multiple schedulable function units, and the scheduled job is placed in the scheduling queue, including: The dispatcher iterates through the scheduled tasks, converts them into schedulable function units, and establishes a set of scheduled jobs for use as the schedulable function units. Scheduling is achieved by switching between different scheduled jobs.

8. An electronic device, comprising: processor; as well as A memory configured to store computer-executable instructions, which, when executed, cause the processor to perform the method of any one of claims 1 to 6.

9. A computer-readable storage medium storing one or more programs, which, when executed by an electronic device including a plurality of applications, cause the electronic device to perform the method of any one of claims 1 to 6.

Citation Information

Patent Citations

  • Recursive scheduling method and system for webpage requests

    CN111177636A

  • Task function processing method and device, equipment, storage medium and program product

    CN115061791A

  • System and method for job scheduling in application servers

    US20090089785A1