A code execution method and device, electronic equipment and storage medium

By embedding detection code in the task code, the first thread detects and executes the task code in the unexecuted state, which solves the problem of long waiting time for tasks in the task queue, realizes the queue execution of tasks, and shortens the business time.

CN122309184APending Publication Date: 2026-06-30BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING ZITIAO NETWORK TECH CO LTD
Filing Date
2024-12-30
Publication Date
2026-06-30

AI Technical Summary

Technical Problem

A large number of tasks queued in the task queue leads to long waiting times for task execution, resulting in longer business processing times.

Method used

By embedding detection code in the first task code, the first thread detects whether the preset task storage module contains second task code that is not in an executed state, and immediately retrieves and executes the second task code when an unexecuted state is detected, thus achieving queue interruption execution.

Benefits of technology

This reduces the queuing time of tasks in the task queue and shortens the processing time of the business to which the task belongs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122309184A_ABST
    Figure CN122309184A_ABST
Patent Text Reader

Abstract

This disclosure provides a code execution method, apparatus, electronic device, and storage medium. The method includes: in response to a preset trigger, acquiring first task code from a first queue via a first thread; if the first task code contains pre-embedded detection code, executing the detection code via the first thread; and if the detection code detects that a second task code in a preset task storage module is in an unexecuted state, acquiring and executing the second task code via the first thread. This reduces the queuing time of tasks in the task queue and shortens the processing time of the business to which the task belongs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and in particular to a code execution method, apparatus, electronic device, and storage medium. Background Technology

[0002] In related technologies, tasks in a task queue typically follow a first-in, first-out (FIFO) principle, being read and executed by threads. When a thread submits a task to another thread's task queue, there's a possibility that a large number of tasks in the queue can cause the submitted task to wait for execution for an extended period, thus prolonging the execution time of the business logic associated with that task. Summary of the Invention

[0003] This disclosure provides a code execution method, apparatus, electronic device, and storage medium that can reduce the queuing time of tasks in the task queue and shorten the time consumed by the business to which the task belongs.

[0004] In a first aspect, embodiments of this disclosure provide a code execution method, including:

[0005] In response to a preset trigger, the first task code in the first queue is retrieved via the first thread;

[0006] If the first task code contains pre-embedded detection code, the detection code is executed through the first thread.

[0007] If the detection code detects that the preset task saving module contains a second task code that is not in an executed state, the second task code is obtained and executed by the first thread.

[0008] Secondly, embodiments of this disclosure also provide a code execution apparatus, including:

[0009] The acquisition module is used to retrieve the first task code in the first queue in response to a preset trigger through the first thread.

[0010] The detection module is used to execute the detection code through the first thread when the first task code has pre-embedded detection code.

[0011] The queue-jumping execution module is used to obtain and execute the second task code through the first thread when the detection code detects that the preset task saving module contains a second task code that is not in an executed state.

[0012] Thirdly, embodiments of this disclosure also provide an electronic device, the electronic device comprising:

[0013] One or more processors;

[0014] Storage device for storing one or more programs.

[0015] When the one or more programs are executed by the one or more processors, the one or more processors implement the code execution method as described in any of the embodiments of this disclosure.

[0016] Fourthly, embodiments of this disclosure also provide a storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to perform the code execution method as described in any of the embodiments of this disclosure.

[0017] Fifthly, this disclosure also provides a computer program product, characterized in that the computer program product includes a computer program, which, when executed by a processor, implements the code execution method as described in any of the embodiments of this disclosure.

[0018] In the technical solution of this disclosure embodiment, in response to a preset trigger, a first task code in a first queue can be obtained through a first thread; if the first task code contains pre-embedded detection code, the detection code is executed through the first thread; if the detection code detects that the preset task storage module contains a second task code in an unexecuted state, the second task code is obtained and executed through the first thread. By pre-embedding detection code in the first task code in the first queue, it is possible to detect whether the preset task storage module contains an unexecuted second task code. And if it contains an unexecuted second task code, the second task code can be immediately retrieved and executed through the first thread. Thus, it is possible to execute the unexecuted second task code in the preset task module without having the second task code queue up in the first queue for execution, thereby reducing the queuing time of the second task code in the first queue and shortening the time consumption of the business to which the second task code belongs. Attached Figure Description

[0019] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale.

[0020] Figure 1 This is a flowchart illustrating a code execution method provided in an embodiment of the present disclosure;

[0021] Figure 2 This is a schematic diagram of the queuing of task codes in the first queue in a code execution method provided by an embodiment of the present disclosure;

[0022] Figure 3A schematic diagram illustrating the queuing of second task code in a code execution method provided in an embodiment of this disclosure;

[0023] Figure 4 This is a flowchart illustrating a code execution method provided in an embodiment of the present disclosure;

[0024] Figure 5 This is a schematic diagram of the structure of a code execution device provided in an embodiment of the present disclosure;

[0025] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation

[0026] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.

[0027] It should be understood that the steps described in the method embodiments of this disclosure may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of this disclosure is not limited in this respect.

[0028] The term "comprising" and its variations as used herein are open-ended inclusions, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the description below.

[0029] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are used only to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.

[0030] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".

[0031] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.

[0032] Figure 1 This is a flowchart illustrating a code execution method provided in an embodiment of this disclosure. This disclosure is applicable to situations involving task code execution, such as when task code submitted by a second thread is interrupted for execution by a first thread. The method can be executed by a code execution device, which can be implemented in software and / or hardware and can be configured in an electronic device, such as within the operating system of a mobile phone, computer, or other electronic device.

[0033] like Figure 1 As shown, the code execution method provided in this embodiment may include:

[0034] S110, In response to a preset trigger, obtain the first task code in the first queue through the first thread.

[0035] In this embodiment of the disclosure, the code execution device can create a first thread and allocate a first queue to the first thread for storing and managing tasks that the first thread needs to execute. The first queue allows tasks to be inserted at the back end and retrieved at the front end. Retrieving a task from the first queue can be considered as deleting the task from the first queue.

[0036] The preset triggers can include triggers to create the first thread and triggers to execute business logic through the first thread. Triggers to create the first thread may include, for example, triggers to cold-start the application. In the case of a cold-start application, a first thread corresponding to the application can be created to execute the application's startup code. Triggers to execute business logic through the first thread may include triggers to access business functions within the application. When a business function entry point in the application is triggered, the corresponding business logic code can be executed through the first thread associated with the application.

[0037] In this embodiment, the code execution device can, in response to a preset trigger, sequentially retrieve tasks (i.e., first task code) from the first queue via a first thread. For example, Figure 2 This is a schematic diagram illustrating the queuing of task codes in the first queue of a code execution method provided in an embodiment of this disclosure. Figure 2 As shown, tasks 1.1 to 1.N can be retrieved sequentially from the first queue using the first thread.

[0038] S120. If the detection code is embedded in the first task code, the detection code is executed through the first thread.

[0039] In this embodiment of the disclosure, it can be determined whether the first task code contains embedded detection code by matching the code identifier or the code content of the detection code. Where the first task code contains embedded detection code, it can be considered that the first task code may include both original business code and detection code. The original business code can be considered as business code not submitted by other threads, whose overall execution logic belongs to the first thread.

[0040] The detection code can be appended before or after the original business logic code. When the detection code is appended before the original business logic code, the detection code can be executed first via the first thread; when the detection code is appended after the original business logic code, the original business logic code can be executed first via the first thread, and the detection code can be executed after the original business logic code has finished executing. For example, as shown... Figure 2 As shown, when task 1.2 is retrieved from the first queue, detection code can be pre-embedded after the original business code in the first task code. In this case, the original business code corresponding to task 1.2 can be executed first through the first thread, and the detection code can be executed through the first thread after the original business code has been executed.

[0041] S130. If the detection code detects that the preset task storage module contains second task code that is not in an executed state, the second task code is obtained and executed by the first thread.

[0042] In this embodiment, the preset task saving module can save task code and the corresponding execution status of the task code. The execution status can include an executed state and a non-executed state. The detection of executable code involves two steps: first, detecting whether the preset task saving module contains second task code; second, detecting the execution status of the contained second task code.

[0043] Specifically, a scenario where the preset task saving module contains second task code, and some of the included second task code is in an unexecuted state, can be considered a scenario where the preset task saving module contains second task code in an unexecuted state. Conversely, a scenario where the preset task saving module does not contain second task code, or a scenario where it contains second task code but all of the included second task code is in an executed state, can both be considered a scenario where the preset task saving module does not contain second task code in an unexecuted state.

[0044] In this embodiment of the disclosure, if the detection code detects that the preset task storage module contains second task code in an unexecuted state, the second task code can be retrieved from the preset task storage module and executed by the first thread. For example, as shown... Figure 2As shown, when task 1.3 is retrieved from the first queue, the detection code can be executed by the first thread. The detection code can also detect that the preset task storage module contains an unexecuted task 2.3 (i.e., the second task code). At this point, the first thread can retrieve task 2.3 from the preset task storage module and execute it. Therefore, it is possible to execute the second task code while the first task code in the first queue is being executed, without the second task code needing to wait in the first queue for execution. This reduces the queuing time of the second task code in the first queue and shortens the processing time of the business logic associated with the second task code.

[0045] Furthermore, when the detection code is appended before the original business code, the original business code in the first task code can be executed again through the first thread after the second task code has been executed; and when the original business code has been executed, a new first task code can be obtained through the first thread. When the detection code is appended after the original business code, the original business code is executed before the detection code, that is, before the second task code; in this case, when the second task code has been executed, a new first task code can be obtained through the first thread. After obtaining the new first task code, steps S120-S130 can be executed again until all tasks in the first queue have been completed.

[0046] In some optional implementations, in response to the completion of the second task code execution, the first thread can set the second task code in the preset task storage module to an executed state. In these optional implementations, after the second task code has been executed by the first thread, the execution state of the second task code in the preset task storage module can be set to an executed state again by the first thread, thereby avoiding the need to execute the second task code again.

[0047] In some optional implementations, it may also include: if the detection code detects that the preset task storage module does not contain second task code in an unexecuted state, and the first task code has been executed, the first thread obtains the new first task code from the first queue.

[0048] If the detection code is appended before the original business code, the detection code can be executed first through the first thread. If the detection code detects that the preset task storage module does not contain the second task code in an unexecuted state, the original business code in the first task code can continue to be executed. At this time, the completion of the original business code can be considered as the completion of the first task code. If the first task code is completed, the first thread can obtain the new first task code from the first queue.

[0049] When the detection code is appended to the original business code, the original business code can be executed first through the first thread, and the detection code can be executed after the original business code has been executed. If the detection code detects that the preset task storage module does not contain the second task code in an unexecuted state, it can be considered that the first task code has been executed. If the first task code has been executed, the first thread can obtain the new first task code from the first queue.

[0050] In these optional implementations, if the preset task storage module does not contain second task code that is not yet executed, a new first task code can be retrieved after the first task code has been executed. After retrieving the new first task code, steps S120-S130 can be executed again until all tasks in the first queue have been completed.

[0051] In the technical solution of this disclosure embodiment, in response to a preset trigger, a first task code in a first queue can be obtained through a first thread; if the first task code contains pre-embedded detection code, the detection code is executed through the first thread; if the detection code detects that the preset task storage module contains a second task code in an unexecuted state, the second task code is obtained and executed through the first thread. By pre-embedding detection code in the first task code in the first queue, it is possible to detect whether the preset task storage module contains an unexecuted second task code. And if it contains an unexecuted second task code, the second task code can be immediately retrieved and executed through the first thread. Thus, it is possible to execute the unexecuted second task code in the preset task module without having the second task code queue up in the first queue for execution, thereby reducing the queuing time of the second task code in the first queue and shortening the time consumption of the business to which the second task code belongs.

[0052] This embodiment can be combined with various optional solutions in the code execution method provided in the above embodiments. The code execution method provided in this embodiment details the submission process of the second task code. After the third task code in the corresponding second queue is completed by the second thread, the second task code can be submitted to the preset task storage module, enabling the second task code to be executed in the queue of the first thread. Furthermore, while submitting the second task code to the preset task storage module, it can also be submitted to the first queue by the second thread for queuing. This ensures that if the second task code misses the detection opportunity in the preset task storage module, it can still be executed as a fallback, guaranteeing the normal operation of the service to which the second task code belongs.

[0053] The code execution method provided in this embodiment, in response to a preset trigger, further includes: after the third task code in the second queue has been executed by the second thread, the second task code is submitted to the preset task storage module by the second thread, and the second task code is configured to an unexecuted state.

[0054] In this context, the second thread differs from the first thread, and any thread that can submit tasks to the first queue can be referred to as a second thread. At least one second thread can be created from the first thread, or from other threads (such as child threads of the first thread). Furthermore, the code execution device can allocate a corresponding second queue to each second thread for storing and managing the tasks that the second thread needs to execute. For example, Figure 3 This is a schematic diagram illustrating the queuing of the second task code in a code execution method provided in an embodiment of this disclosure. Figure 3 As shown, the code for the third task in the second queue is executed by the second thread (e.g., ...). Figure 3 In the case of tasks 2.1 and 2.2, the code for the second task (such as...) can be passed through a second thread. Figure 3 Task 2.3) is submitted to the preset task saving module, and the second task code can be configured to be in an inactive state. See also... Figure 2 It can be in the first task code (such as Figure 2 Section 1.3) contains pre-embedded detection code, and this detection code detects the second task code (such as...) that has not been executed in the preset task saving module. Figure 3 In the case of task 2.3, task 2.3 can be retrieved from the preset task storage module and executed by the first thread. Thus, task 2.3 can be executed before tasks 1.4-1.N-1 in the first queue, thereby reducing the queuing time of task 2.3 in the first queue.

[0055] In some optional implementations, while submitting the second task code to the preset task saving module via a second thread, it may also include: submitting the second task code to the first queue via a second thread. See again. Figure 3 The second task code (such as...) is passed through the second thread. Figure 3 While submitting task 2.3 to the preset task saving module, the second task code (such as...) can also be submitted via a second thread. Figure 3 Task 2.3 is submitted to the first queue, that is, it is inserted after Task 1.N-1.

[0056] Correspondingly, the method may also include: if the first task code belongs to the second task code in the preset task saving module and is not in an executed state, executing the first task code through the first thread.

[0057] The first task code belongs to the second task code in the preset task storage module. This can be understood as the first task code being historically stored in the preset task storage module as part of the second task code, or currently stored there. Whether the first task code belongs to the second task code in the preset task storage module can be determined by checking if the code identifiers or code contents of the first and second task codes match. At this point, the execution status of the first task code can be queried from the preset storage module. If the execution status is "not executed," the first task code is considered to belong to the second task code in the preset task storage module that is not currently being executed, and it can then be executed by the first thread. Furthermore, once the first task code has completed execution, a new first task code can be obtained through the first thread.

[0058] Furthermore, if the first task code belongs to the second task code that is already in the executed state in the preset task storage module, a new first task code can be obtained from the first queue through the first thread. Specifically, if the first task code belongs to the second task code in the preset task storage module and its execution state is already executed, it can be considered that the first task code belongs to the second task code that is already in the executed state in the preset task storage module. In this case, the execution of the first task code can be stopped, and a new first task code can be obtained through the first thread.

[0059] For example, see again Figure 3 If the first task code retrieved from the first queue is task 2.3, then task 2.3 can be considered to belong to the preset storage module. When task 2.3 is already executed, it can be skipped directly, and the main program can obtain the new first task code (i.e., obtain task 1.N). When task 2.3 is not yet executed, it can be executed, and after task 2.3 completes, the main program can obtain the new first task code (i.e., obtain task 1.N). Since the second task code in the preset task storage module already needs to be queued for execution in the first queue, detecting and executing the second task code in advance will not affect thread safety.

[0060] In addition, if the first task code belonging to the preset task saving module is obtained and the first task code has been executed, the first task code can be deleted from the preset task saving module to improve the storage resource utilization of the preset task saving module.

[0061] Among these optional implementation methods, while submitting the second task code to the preset task saving module, the second task code can also be submitted to the first queue for queuing through the second thread. This ensures that the second task code is executed as a fallback if it misses the detection opportunity in the preset task saving module, thus guaranteeing the normal operation of the business to which the second task code belongs.

[0062] Figure 4 This is a flowchart illustrating a code execution method provided in an embodiment of this disclosure. Figure 4 As shown, the code execution method provided in this embodiment may include:

[0063] S401, In response to a preset trigger, obtain the first task code through the first thread.

[0064] S402. Determine if the first task code has pre-embedded detection code; if so, jump to S403; otherwise, jump to S409.

[0065] Among them, it can be determined whether there is pre-embedded detection code in the code of the first task by detecting code identifier matching or code content matching.

[0066] S403, Execute the detection code through the first thread.

[0067] Specifically, if the detection code is appended before the original business code, the detection code can be executed first through the first thread; if the detection code is appended after the original business code, the original business code can be executed first through the first thread, and the detection code can be executed after the original business code has been executed.

[0068] S404. Check whether the preset task saving module contains a second task code that is not executed; if so, jump to S405; otherwise, jump to S408.

[0069] If the detection code detects that the preset task storage module contains second task code that is not yet executed, then S405 is executed; if the detection code detects that the preset task storage module does not contain second task code that is not yet executed, then S408 is executed, and if the original business code is not executed, the original business code can be completed by the first thread.

[0070] S405. Obtain the code for the second task through the first thread and execute it.

[0071] S406. In response to the completion of the second task code execution, the second task code in the preset task saving module is set to the executed state through the first thread.

[0072] S407. If the first and second task codes have been executed, jump to S411.

[0073] S408. If the first task code has been executed, jump to S411.

[0074] Specifically, if the first task code includes both original business logic and detection code, its completion is considered complete when the first thread executes both the original business logic and the detection code. If the first task code includes original business logic but does not include detection code, its completion is considered complete when the first thread executes the original business logic. If the first task code is part of the second task code, its completion is considered complete when the first thread executes the second business logic.

[0075] S409. Determine whether the first task code belongs to the second task code in the preset task saving module; if yes, jump to S410; otherwise, jump to S408.

[0076] In the case where no detection code is pre-embedded in the first task code, the first task code can be either the original business code in the first queue or the second task code belonging to the preset task storage module. Whether the first task code belongs to the second task code in the preset task storage module can be determined by checking if the code identifiers or code contents of the first and second task codes match. If the first task code belongs to the second task code, S410 can be executed; if the first task code belongs to the original business code, the original business code can be executed by the first thread, and then S408 can be executed.

[0077] S410. Determine whether the second task code is in an unexecuted state; if yes, jump to S408; otherwise, jump to S411.

[0078] If the second task code is in an unexecuted state, the second business code can be executed through the first thread, and S408 can be executed. If the second task code is not in an unexecuted state, it can be considered to be in an executed state, and the second task code can be skipped and deleted from the preset save module.

[0079] S411. Obtain the new first task code from the first queue through the first thread until the first task code in the first queue has finished running.

[0080] If a new first task code is obtained, the above steps can be repeated until the first task code in the first queue has finished running.

[0081] For example, in some optional implementations, the preset trigger may include the rendering trigger of the target interface; the second task code can be used to refresh the preprocessed data to the target interface.

[0082] The preset triggers can include rendering triggers for the target interface within the application, such as triggers for the target interface's entry point. If the first thread needs to render the target interface, a second thread can be created to perform pre-processing operations such as acquiring and parsing the data required by the target interface. After the second thread finishes processing the data, the second task code can be submitted to the preset task saving module. Thus, with pre-embedded detection code in the first task code, the second task code can be executed by the first thread to refresh the pre-processed data to the target interface. Figure 3 Taking Task 2.3 as an example, assuming the second task code is Task 2.3, the first task code, which contains pre-embedded detection code (such as Task 1.2 and Task 1.3), can detect whether Task 2.3 is stored in the preset task storage module and is in an unexecuted state. Once detected, Task 2.3 can be retrieved and executed through the first thread to refresh the preprocessed data to the target interface.

[0083] In related technologies, after the second thread finishes processing the data, it needs to submit its task to the first queue to wait for the interface to refresh based on the pre-processed data. A long waiting time leads to slow page refresh and a poor user experience. Among these alternative implementations, a first task code with pre-embedded detection code can provide an opportunity for the second code to be executed in the queue. If any of the first task code with pre-embedded detection code detects that an unexecuted second task code is stored in the preset task storage module, it can retrieve and execute it, quickly refreshing the pre-processed data to the target interface, thus improving the user experience.

[0084] The technical solution of this disclosure describes in detail the submission process of the second task code. After the third task code in the corresponding second queue is completed by the second thread, the second task code can be submitted to the preset task storage module, enabling the second task code to be executed in the queue of the first thread. Furthermore, while submitting the second task code to the preset task storage module, it can also be submitted to the first queue by the second thread for queuing. This ensures that if the second task code misses the detection opportunity in the preset task storage module, it can still be executed as a fallback, guaranteeing the normal operation of the service to which the second task code belongs. The code execution method provided in this disclosure belongs to the same concept as the code execution method provided in the above embodiments. Technical details not described in detail in this embodiment can be found in the above embodiments, and the same technical features have the same beneficial effects in this embodiment and the above embodiments.

[0085] This embodiment can be combined with various optional schemes in the code execution method provided in the above embodiments. The code execution method provided in this embodiment describes in detail the pre-embedding step of the detection code. By combining the execution logic and execution time of each task in the queue corresponding to the first thread, and the timing of task submission to the queue corresponding to each second thread, the target business code that needs to be set with the detection code can be determined from the original business code executed by the first thread, thereby realizing the pre-embedding of the detection code and laying the foundation for the queue-jumping execution of the second task code.

[0086] The code execution method provided in this embodiment includes a process for generating a first task code with embedded detection code, comprising: determining the target business code from the original business code based on the execution logic and execution time of the original business code in the first queue and the execution time of the third task code in the second queue; and generating the first task code based on the target business code and the detection code.

[0087] In this embodiment, during the code development phase, first task code containing detection code can be generated. Therefore, during the execution of the first task code, the detection code can detect whether the preset task storage module contains second task code that is not yet executed.

[0088] The process of generating the first task code with pre-embedded detection code may include: estimating the execution time of the third task code based on the historical execution time of the third task code in the second queue; estimating the execution time of the original business code based on the historical execution time of the original business code in the first queue; accumulating the execution time of the original business code in the first queue according to the execution logic until the accumulated time is greater than the execution time of the third task code, and then determining the corresponding original business code as the target business code.

[0089] Since the second task code submitted to the first queue includes at least one, the corresponding target business code can be determined based on the execution time of the third task code corresponding to each second task code. Therefore, it can be assumed that at least one original business code in the first queue can be identified as the target business code.

[0090] In addition, based on determining the corresponding target business code according to the execution time of the third task code, a preset number of original business codes can be selected before and after the target business code as target business codes to expand the detection range and ensure the detection hit rate of the second task code that has not been executed in the preset task storage module.

[0091] After determining the target business code, the detection code can be appended before or after the target business code to generate the first task code with the pre-embedded detection code.

[0092] The technical solution of this disclosure provides a detailed description of the pre-embedding step of the detection code. By combining the execution logic and execution time of each task in the queue corresponding to the first thread, and the timing of task submission to the queue corresponding to each second thread, the target business code that needs to be set with the detection code can be determined from the original business code executed by the first thread. This enables the pre-embedding of the detection code and lays the foundation for the queue-jumping execution of the second task code. The code execution method provided in this disclosure belongs to the same disclosure concept as the code execution method provided in the above embodiments. Technical details not described in detail in this embodiment can be found in the above embodiments, and the same technical features have the same beneficial effects in this embodiment and the above embodiments.

[0093] Figure 5 This is a schematic diagram of a code execution device provided in an embodiment of the present disclosure. The code execution device provided in this embodiment is applicable to the execution of task code, such as the situation where task code submitted by a second thread is executed in advance by a first thread.

[0094] like Figure 5 As shown, the code execution apparatus provided in this embodiment may include:

[0095] The acquisition module 510 is used to retrieve the first task code in the first queue in response to a preset trigger through the first thread;

[0096] The detection module 520 is used to execute the detection code through the first thread when the detection code is embedded in the first task code;

[0097] The queue-jumping execution module 530 is used to obtain and execute the second task code through the first thread when the detection code detects that the preset task storage module contains a second task code that is not in an executed state.

[0098] In some alternative implementations, the code execution device may also include:

[0099] The task submission module is used to submit the second task code to the preset task saving module through the second thread after the third task code in the second queue has been executed through the second thread, and to configure the second task code as an unexecuted state.

[0100] In some alternative implementations, the queue-jumping execution module is also used for:

[0101] In response to the completion of the second task code execution, the queue execution module can be used to set the second task code in the preset task saving module to the executed state.

[0102] In some alternative implementations, the task submission module can also be used for:

[0103] While submitting the second task code to the preset task saving module through the second thread, the second task code is also submitted to the first queue through the second thread;

[0104] The code execution device may further include:

[0105] The queued execution module is used to execute the first task code through the first thread when the first task code belongs to the second task code that is not in the preset task storage module.

[0106] In some alternative implementations, the module acquisition method can also be used for:

[0107] If the first task code is a second task code that has already been executed in the preset task saving module, the new first task code is obtained from the first queue through the first thread.

[0108] In some alternative implementations, the module acquisition method can also be used for:

[0109] If the detection code detects that the preset task storage module does not contain any second task code that is not yet executed, and the first task code has been executed, the first thread retrieves the new first task code from the first queue.

[0110] In some alternative implementations, the code execution module may also include:

[0111] The code generation module is used to generate the first task code, which contains pre-embedded detection code, through the following process:

[0112] Based on the execution logic and execution time of the original business code in the first queue, and the execution time of the third task code in the second queue, the target business code is determined from the original business code;

[0113] Generate the first task code based on the target business code and the detection code.

[0114] In some optional implementations, the preset trigger includes the rendering trigger of the target interface; the second task code is used to refresh the preprocessed data to the target interface.

[0115] The code execution apparatus provided in this disclosure can execute the code execution method provided in any embodiment of this disclosure, and has the corresponding functional modules and beneficial effects of the execution method.

[0116] It is worth noting that the various units and modules included in the above-mentioned device are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be realized; in addition, the specific names of each functional unit are only for easy differentiation and are not used to limit the protection scope of the embodiments of this disclosure.

[0117] The following is for reference. Figure 6 It illustrates an electronic device suitable for implementing embodiments of the present disclosure (e.g., Figure 6 The diagram below shows the structure of the terminal device or server 600. The terminal device in this embodiment may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), and vehicle terminals (e.g., vehicle navigation terminals), as well as fixed terminals such as digital TVs and desktop computers. Figure 6 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.

[0118] like Figure 6 As shown, electronic device 600 may include a processing unit (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 602 or a program loaded from storage device 608 into random access memory (RAM) 603. The RAM 603 also stores various programs and data required for the operation of electronic device 600. The processing unit 601, ROM 602, and RAM 603 are interconnected via bus 604. An input / output (I / O) interface 605 is also connected to bus 604.

[0119] Typically, the following devices can be connected to I / O interface 605: input devices 606 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 607 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 608 including, for example, magnetic tapes, hard disks, etc.; and communication devices 609. Communication device 609 allows electronic device 600 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 6 An electronic device 600 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.

[0120] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by a processing device 601, it performs the functions defined in the code execution method of embodiments of this disclosure.

[0121] The electronic device provided in this embodiment and the code execution method provided in the above embodiments belong to the same disclosed concept. Technical details not described in detail in this embodiment can be found in the above embodiments, and this embodiment has the same beneficial effects as the above embodiments.

[0122] This disclosure provides a storage medium for computer-executable instructions, which, when executed by a computer processor, can be used to execute the code execution method provided in the above embodiments.

[0123] It should be noted that the storage medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM) or flash memory (FLASH), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium that contains or stores executable instructions that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable executable instructions. Such transmitted data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit executable instructions for use by or in connection with an instruction execution system, apparatus, or device. Executable instructions contained on the storage medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.

[0124] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and end-to-end networks (e.g., ad hoc end-to-end networks), as well as any currently known or future-developed networks.

[0125] The aforementioned storage medium may be included in the aforementioned electronic device; or it may exist independently and not be assembled into the electronic device.

[0126] The aforementioned storage medium carries one or more executable instructions, which, when executed by the electronic device, cause the electronic device to:

[0127] In response to a preset trigger, the first task code in the first queue is obtained through the first thread; if the first task code contains pre-embedded detection code, the detection code is executed through the first thread; if the detection code detects that the preset task storage module contains a second task code that is not in an executed state, the second task code is obtained and executed through the first thread.

[0128] Executable instructions for performing the operations of this disclosure can be written in one or more programming languages ​​or a combination thereof, including but not limited to object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as the "C" language or similar programming languages. The executable instructions can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0129] This disclosure also provides a computer program product, including a computer program that, when executed by a processor, can implement the code execution method provided in any embodiment of this disclosure.

[0130] In implementing a computer program product, computer program code for performing the operations of this disclosure can be written in one or more programming languages ​​or a combination thereof. Programming languages ​​include object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as C or similar languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0131] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0132] The units described in the embodiments of this disclosure can be implemented in software or hardware. The names of the units and modules do not, in certain circumstances, constitute a limitation on the unit or module itself.

[0133] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Array (FPGA), Application Specific Integrated Circuit (ASIC), Application Specific Standard Parts (ASSP), System on Chip (SOC), Complex Programmable Logic Device (CPLD), and so on.

[0134] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0135] According to one or more embodiments of this disclosure, a code execution method is provided, the method comprising:

[0136] In response to a preset trigger, the first task code in the first queue is retrieved via the first thread;

[0137] If the first task code contains pre-embedded detection code, the detection code is executed through the first thread.

[0138] If the detection code detects that the preset task saving module contains a second task code that is not in an executed state, the second task code is obtained and executed by the first thread.

[0139] According to one or more embodiments of this disclosure, a code execution method is provided, further comprising:

[0140] In some optional implementations, in response to the preset trigger, the method further includes:

[0141] After the third task code in the second queue is executed by the second thread, the second task code is submitted to the preset task saving module by the second thread, and the second task code is configured as an unexecuted state.

[0142] According to one or more embodiments of this disclosure, a code execution method is provided, further comprising:

[0143] In some optional implementations, in response to the completion of the second task code execution, the first thread sets the second task code in the preset task saving module to an executed state.

[0144] According to one or more embodiments of this disclosure, a code execution method is provided, further comprising:

[0145] In some optional implementations, while submitting the second task code to the preset task saving module via the second thread, the method further includes:

[0146] The second task code is submitted to the first queue via the second thread;

[0147] The method further includes:

[0148] If the first task code belongs to the second task code that is not executed in the preset task saving module, the first task code is executed by the first thread.

[0149] According to one or more embodiments of this disclosure, a code execution method is provided, further comprising:

[0150] Some alternative implementations also include:

[0151] If the first task code belongs to the second task code that is already executed in the preset task saving module, the first thread retrieves the new first task code from the first queue.

[0152] According to one or more embodiments of this disclosure, a code execution method is provided, further comprising:

[0153] Some alternative implementations also include:

[0154] If the detection code detects that the preset task saving module does not contain any second task code that is not yet executed, and the first task code has been executed, the first thread retrieves the new first task code from the first queue.

[0155] According to one or more embodiments of this disclosure, a code execution method is provided, further comprising:

[0156] In some optional implementations, the generation process of the first task code, which pre-embeds the detection code, includes:

[0157] Based on the execution logic and execution time of the original business code in the first queue, and the execution time of the third task code in the second queue, the target business code is determined from the original business code;

[0158] The first task code is generated based on the target business code and the detection code.

[0159] According to one or more embodiments of this disclosure, a code execution method is provided, further comprising:

[0160] In some optional implementations, the preset trigger includes the rendering trigger of the target interface; the second task code is used to refresh the preprocessed data to the target interface.

[0161] According to one or more embodiments of the present disclosure, a code execution apparatus is provided, the apparatus comprising:

[0162] The acquisition module is used to retrieve the first task code in the first queue in response to a preset trigger through the first thread.

[0163] The detection module is used to execute the detection code through the first thread when the first task code has pre-embedded detection code.

[0164] The queue-jumping execution module is used to obtain and execute the second task code through the first thread when the detection code detects that the preset task saving module contains a second task code that is not in an executed state.

[0165] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.

[0166] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.

[0167] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.

Claims

1. A code execution method, characterized in that, include: In response to a preset trigger, the first task code in the first queue is retrieved via the first thread; If the first task code contains pre-embedded detection code, the detection code is executed through the first thread. If the detection code detects that the preset task saving module contains a second task code that is not in an executed state, the second task code is obtained and executed by the first thread.

2. The method according to claim 1, characterized in that, In response to the preset trigger, it also includes: After the third task code in the second queue is executed by the second thread, the second task code is submitted to the preset task saving module by the second thread, and the second task code is configured as an unexecuted state.

3. The method according to claim 1, characterized in that, Also includes: In response to the completion of the second task code execution, the first thread sets the second task code in the preset task saving module to the executed state.

4. The method according to claim 2, characterized in that, Simultaneously with submitting the second task code to the preset task saving module via the second thread, the method further includes: The second task code is submitted to the first queue via the second thread; The method further includes: If the first task code belongs to the second task code that is not executed in the preset task saving module, the first task code is executed by the first thread.

5. The method according to claim 4, characterized in that, Also includes: If the first task code belongs to the second task code that is already executed in the preset task saving module, the first thread retrieves the new first task code from the first queue.

6. The method according to claim 1, characterized in that, Also includes: If the detection code detects that the preset task saving module does not contain any second task code that is not yet executed, and the first task code has been executed, the first thread retrieves the new first task code from the first queue.

7. The method according to claim 2, characterized in that, The process of generating the first task code, which pre-embeds the detection code, includes: Based on the execution logic and execution time of the original business code in the first queue, and the execution time of the third task code in the second queue, the target business code is determined from the original business code; The first task code is generated based on the target business code and the detection code.

8. The method according to any one of claims 1-7, characterized in that, The preset trigger includes the rendering trigger of the target interface; the second task code is used to refresh the preprocessed data to the target interface.

9. A code execution device, characterized in that, include: The acquisition module is used to retrieve the first task code in the first queue in response to a preset trigger through the first thread. The detection module is used to execute the detection code through the first thread when the first task code has pre-embedded detection code. The queue-jumping execution module is used to obtain and execute the second task code through the first thread when the detection code detects that the preset task saving module contains a second task code that is not in an executed state.

10. An electronic device, characterized in that, The electronic device includes: One or more processors; Storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the code execution method as described in any one of claims 1-8.

11. A storage medium comprising computer-executable instructions, which, when executed by a computer processor, are used to perform the code execution method as described in any one of claims 1-8.

12. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the code execution method as described in any one of claims 1-8.