CN112286656A - Applet simulation method, apparatus, electronic device and computer readable storage medium - Google Patents

Applet simulation method, apparatus, electronic device and computer readable storage medium Download PDF

Info

Publication number
CN112286656A
CN112286656A CN202011131957.1A CN202011131957A CN112286656A CN 112286656 A CN112286656 A CN 112286656A CN 202011131957 A CN202011131957 A CN 202011131957A CN 112286656 A CN112286656 A CN 112286656A
Authority
CN
China
Prior art keywords
simulator
applet
shared memory
main process
execution result
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202011131957.1A
Other languages
Chinese (zh)
Other versions
CN112286656B (en
Inventor
石鑫哲
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN202011131957.1A priority Critical patent/CN112286656B/en
Publication of CN112286656A publication Critical patent/CN112286656A/en
Application granted granted Critical
Publication of CN112286656B publication Critical patent/CN112286656B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/52Program synchronisation; Mutual exclusion, e.g. by means of semaphores
    • G06F9/524Deadlock detection or avoidance
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/544Buffers; Shared memory; Pipes
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The application discloses a small program simulation method and device, electronic equipment and a computer readable storage medium, and relates to the technical field of small programs. The specific implementation scheme is as follows: under the condition of updating the small program, the simulator main process sends a reloading instruction to the simulator working thread; reloading the simulator working thread to obtain updated small program data, and sending the updated small program data to the simulator main process; and the simulator main process simulates the small program to run according to the updated small program data. The method and the device can improve the simulation efficiency of the small program, so that the development efficiency of the small program is improved.

Description

Applet simulation method, apparatus, electronic device and computer readable storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for simulating an applet, an electronic device, and a computer-readable storage medium.
Background
With the continuous application of applets in various fields of work and life, the number of applets to be developed is increasing. The applet development tool is used for helping a developer to develop and debug the applet simply and efficiently, and supports functions of API (Application Programming Interface) of the applet, development and debugging of a page, code viewing, applet previewing and publishing and the like.
The small program development tool comprises a simulator which is used for simulating the effect of the small program running on the mobile terminal host application. The applet developer can adjust the page style and debug the service logic on the simulator, and can also switch user agents (users) of different mobile terminals, with aspect ratio, to simulate different applet entries.
Disclosure of Invention
The present disclosure provides a method, an apparatus, an electronic device, and a computer-readable storage medium for applet simulation.
According to an aspect of the present disclosure, there is provided an applet simulation method including:
under the condition of updating the small program, the simulator main process sends a reloading instruction to the simulator working thread;
reloading the simulator working thread to obtain updated small program data, and sending the updated small program data to the simulator main process;
and the simulator main process simulates the small program to run according to the updated small program data.
According to an aspect of the present disclosure, there is provided an applet simulation apparatus including:
the simulator main process is used for sending a reloading instruction to the simulator working thread under the condition of updating the applet;
the simulator working thread is used for reloading to obtain updated applet data and sending the updated applet data to the simulator main process;
and the simulator main process is also used for simulating the small program to run according to the updated small program data.
According to a third aspect, there is provided an electronic device comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform an applet simulation method as claimed in any one of the embodiments of the application.
According to a fourth aspect, there is provided a non-transitory computer readable storage medium having stored thereon computer instructions for causing the computer to perform the applet simulation method as in any one of the embodiments of the application.
According to the technology of the application, the simulation efficiency of the small program can be improved, and therefore the development efficiency of the small program is improved.
It should be understood that the statements in this section do not necessarily identify key or critical features of the embodiments of the present disclosure, nor do they limit the scope of the present disclosure. Other features of the present disclosure will become apparent from the following description.
Drawings
The drawings are included to provide a better understanding of the present solution and are not intended to limit the present application. Wherein:
fig. 1 is a schematic flowchart of an applet simulation method according to an embodiment of the present application;
FIG. 2 is a schematic flow chart diagram of another applet simulation method provided in accordance with an embodiment of the present application;
FIG. 3 is a schematic flow chart diagram illustrating another applet simulation method provided in accordance with an embodiment of the present application;
FIGS. 4 a-4 d are timing diagrams of synchronous communications, respectively, provided in accordance with embodiments of the present application;
FIG. 5 is a schematic structural diagram of an applet simulation apparatus according to an embodiment of the present application;
fig. 6 is a block diagram of an electronic device for implementing the applet simulation method according to an embodiment of the application.
Detailed Description
The following description of the exemplary embodiments of the present application, taken in conjunction with the accompanying drawings, includes various details of the embodiments of the application for the understanding of the same, which are to be considered exemplary only. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present application. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Fig. 1 is a schematic flowchart of an applet simulation method according to an embodiment of the present application. The method and the device can be applied to the situation that the operation effect of the small program is simulated through the simulator in the small program development tool in the small program development process. The applet simulation method disclosed in this embodiment may be executed by an electronic device, and specifically may be executed by an applet simulation apparatus, which may be implemented by software and/or hardware and configured in the electronic device. Referring to fig. 1, the applet simulation method provided in this embodiment includes:
and S110, under the condition of updating the small program, the simulator main process sends a reloading instruction to the simulator working thread.
And S120, reloading the simulator working thread to obtain updated applet data, and sending the updated applet data to the simulator main process.
And S130, simulating the small program to run by the simulator main process according to the updated small program data.
The simulator main process is an execution entity of simulator codes in the small program development tool. The applet development tool includes a compiler process, a debugger process, a rendering process, etc., in addition to the simulator main process. In the applet simulation process, the applet code may need to be updated. In the small program simulation process, a small program developer (namely, a small program research and development worker) modifies a small program code, stores a modified small program file, compiles and debugs the modified small program file through a compiling process and a debugging process in a small program development tool, informs a rendering process after compiling and debugging are completed, informs a simulator main process of the rendering process, and sends a reloading instruction to a simulator working thread after the simulator main process receives the notice. Specifically, the rendering process may send a refresh notification message to the simulator host process, and the simulator host process may send a reload instruction to the simulator worker thread after receiving the refresh notification message.
The simulator working thread responds to the reloading instruction, reloading, namely killing (kill) and restarting is carried out, updated small program data are obtained in the restarting process, the simulator working thread is further interacted with the simulator main process, the updated small program data are sent to the simulator main process, and the simulator main process simulates the small program running process according to the updated small program data. Wherein the updated applet data is determined from the modified applet file.
In the embodiment of the application, a main process (master) and a working thread (worker) are matched and introduced into an applet development tool, a simulator working thread is used as an inlet of a simulator main process, under the condition of applet updating, the simulator working thread is reloaded to obtain updated applet data, and the simulator main process receives the updated applet data from the simulator working thread and simulates applet running according to the updated applet data. In other words, in the applet updating process, the simulator working thread is only required to be reloaded, the simulator main process is not required to be reloaded, and the applet refreshing efficiency in the applet simulating process can be improved, so that the applet simulating efficiency and the applet developing efficiency can be improved. In addition, the reloading speed of the simulator working thread is far higher than the speed of refreshing the webview (webpage view), so that the small program refreshing speed can be improved compared with the method of directly loading the simulator main process through the webview in a cross-platform desktop application program (electronic).
According to the technical scheme, the simulator working thread is introduced to serve as the entrance of the simulator main process, under the condition of small program updating, the simulator working thread only needs to be reloaded, the simulator working thread interacts with the simulator main process, updated small program data are transmitted to the simulator main process, the simulator main process simulates according to the updated small program data, small program updating efficiency in the simulation process is improved, and therefore small program development efficiency is improved.
Fig. 2 is a schematic flowchart of an applet simulation method according to an embodiment of the present application. The present embodiment is an alternative proposed on the basis of the above-described embodiments. Referring to fig. 2, the applet simulation method provided in this embodiment includes:
s210, under the condition of updating the small program, the simulator main process sends a reloading instruction to the simulator working thread.
S220, reloading the simulator working thread to obtain updated applet data, and sending the updated applet data to the simulator main process.
And S230, the simulator main process responds to the function call instruction sent by the simulator working thread according to the updated applet data, executes the function to be called to obtain an execution result, and writes the execution result into the shared memory.
S240, the simulator working thread waits when detecting that the execution result in the shared memory is not written into.
And S250, when the simulator main process detects that the execution result in the shared memory is written in, waking up the simulator working thread, and reading the execution result from the shared memory by the simulator working thread.
The host process and the worker thread in worker thread mode generally do not support synchronous communication. The embodiment of the application can support synchronous communication of the working threads by matching the shared memory with the atomic operation. The calling party is in the simulator working thread and is realized by the simulator main process. The simulator working thread can send a function calling instruction to the simulator main process according to the updated applet data, wherein the function calling instruction at least comprises a function identifier to be called and a function parameter, the simulator main process responds to the function calling instruction to execute the function to be called to obtain an execution result, and the execution result is written into the shared memory.
After the simulator worker thread sends the function call instruction, whether the execution result in the shared memory is written in is detected, and under the condition that the writing is not finished, the simulator worker thread can enter a waiting state through an atomic waiting lock such as atomic. In the waiting process of the working thread of the simulator, when detecting that the execution result in the shared memory is written, the main process of the simulator can wake up the working thread of the simulator through atomic wake up such as atomic wake (), and the working thread of the simulator reads the execution result from the shared memory after waking up.
In the view of the main process of the simulator, the function calling communication process belongs to asynchronous communication, and because the middle of the working thread of the simulator is in a waiting state, the event loop (event loop) of the working thread of the simulator is not updated to the next round, and the execution stack is not executed completely until the working thread of the simulator is awakened by the main process of the simulator, namely, in the view of the working thread of the simulator, the function calling communication process belongs to synchronous communication. And because the simulator working thread enters a waiting state under the condition that the execution result in the shared memory is not written into the shared memory, and then the simulator main process wakes up the simulator working thread under the condition that the simulator main process detects that the execution result in the shared memory is written into the shared memory, deadlock abnormity caused by the fact that the simulator working thread enters the waiting state after receiving atomic wake-up can be avoided.
In an alternative embodiment, the simulator main process simulating the applet running according to the updated applet data comprises the following steps: the simulator main process responds to a function call instruction sent by the simulator working thread according to the updated applet data, executes the function to be called to obtain an execution result, and writes the execution result into the shared memory; and the simulator working thread reads the execution result from the shared memory when detecting that the execution result in the shared memory is written into the shared memory.
Specifically, after sending a function call instruction to the simulator main process, the simulator working thread detects whether the execution result in the shared memory is written in, and under the condition that the writing is finished, the simulator working thread does not need to enter a waiting state, and the execution result is directly read from the shared memory. Before the simulator working thread enters the waiting state, if the execution result in the shared memory is written into the simulator working thread, the simulator working thread does not need to enter the waiting state, so that deadlock abnormity can be avoided, and the working efficiency of the simulator working thread can be improved.
It should be noted that, in the synchronous communication process, when the length of the data to be transmitted exceeds the capacity of the shared memory, the data may be sent in segments, so as to avoid the synchronous communication process being restricted by the capacity of the shared memory. The number of the fragments can be determined according to the length of the data to be transmitted and the capacity of the shared memory.
It should be noted that, since the main process and the worker thread in the worker thread mode can generally support asynchronous communication, the applet to be simulated can also call an asynchronous communication function. Specifically, in the process of calling the asynchronous communication function, the simulator working thread can send an asynchronous function calling instruction to the simulator main process according to the updated applet data and process a message returned from the simulator main process; the simulator main process monitors a function call instruction sent by the simulator working thread, executes a function to be called to obtain an execution result, and sends the execution result to the simulator working thread.
In an optional implementation manner, after writing the execution result to the shared memory, the method further includes: the simulator main process writes a wake-up identifier into the shared memory; the wake-up identifier is used for representing whether the execution result in the shared memory is written in. By writing the wake-up flag into the shared memory, the simulator can conveniently detect the work of the simulator to determine whether the execution result in the shared memory is written into.
In an optional implementation manner, the function call instruction includes a function call identifier, and the function call identifier is unique and is used to write the function call identifier into the shared memory as the wake-up identifier. Specifically, after the execution result is written into the shared memory by the main process of the simulator, the unique function call identifier in the function call instruction is written into the shared memory as the wake-up identifier, so that the simulator can conveniently detect the work to determine whether the execution result in the shared memory is written into the shared memory.
In addition, in order to control the state of the worker thread, the state control information of the worker thread may also be written into the shared memory, such as a wait state atomic.
According to the technical scheme, synchronous communication of the simulator working threads can be supported through cooperation of the shared memory and atomic operation, the simulator working threads are not waited until the simulator main detection successfully writes the execution result into the shared memory after detection that the execution result in the shared memory is not written into the shared memory, and deadlock abnormity in the synchronous communication process can be avoided.
Fig. 3 is a schematic flowchart of an applet simulation method according to an embodiment of the present application. The present embodiment is an alternative proposed on the basis of the above-described embodiments. Referring to fig. 3, the applet simulation method provided in this embodiment includes:
s301, under the condition of updating the small program, the simulator main process sends a reloading instruction to the simulator working thread.
S302, reloading the simulator working thread to obtain updated applet data, and sending the updated applet data to the simulator main process.
Specifically, the rendering process may notify the simulator via the simulator host process that the worker thread reloads. After the rendering process monitors that the simulator working thread is reloaded, a small program completion preparation message can be sent to the simulator working thread through the simulator main process, a page preparation message can also be sent to a slave process (slave process) of the main process of the small program development tool by the rendering process, after the slave process is prepared, the slave process preparation completion message is sent to the simulator main process by the rendering process, and after the simulator main process monitors the message, the slave process interacts with the simulator working thread to obtain updated small program data.
And S303, updating the applet page by the simulator main process through the rendering process according to the updated applet data.
Specifically, the simulator main process also sends the updated applet data to the rendering process, the rendering process sends the updated applet data to the slave process, and the slave process renders the applet page according to the updated applet data. In the updating process of the small program, the refreshing efficiency of the small program page can be improved only by reloading the working thread of the simulator.
In an alternative embodiment, the method further comprises: in the starting process of the simulator, the simulator main process also preloads an applet interface for the applet to be simulated, so that the development efficiency of the applet is improved. The applet interface refers to an applet interface provided by an applet development tool in advance, and may include at least one of the following: the system comprises a base, a route, a network, an interface, a data store, an Artificial Intelligence (AI), media, a location, a canvas, a device, a third party platform, an open interface, a user interface, a server interface, a promotion interface, and the like.
The small program interface (simulation API) is placed in a simulator main process, the small program to be simulated calls the small program interface through the simulator main process, and a simulator working thread is independent of the simulator main process and a preloaded small program interface. Under the condition that the applet to be simulated is updated, the simulator main process and the preloaded applet interface do not need to be reloaded, and the applet simulation efficiency is improved. Moreover, the small program interface part does not need to be reconstructed, namely, the research and development workload of a small program development tool does not need to be increased.
It should be noted that the applet development tool can be started in the following manner: the method comprises the steps that a main process of the simulator is pre-created in a rendering process, and initialization data of the main process of the simulator are sent, wherein the initialization data can be data used by a developer tool, such as the type of the simulator, the type of a panel for simulating operation and the like; starting a simulator working thread by a simulator main process; initializing a slave process; the simulator main process sends a creation completion message to the rendering process; the rendering process sends a simulator host process preparation complete message to the debugger process.
Moreover, because the slave process can be destroyed, the rendering process can pre-create the slave process, so that the subsequent use is facilitated; sending a slave process creation completion message to the rendering process after the slave process creation is completed; the rendering process sends a slave process ready completion (slave-ready message) to the debugger process, i.e. the applet development tool completes the launch. In the embodiment of the application, only one simulator main process is needed, the simulator main process cannot be destroyed, and the simulator working thread and the slave process can be destroyed.
According to the technical scheme of the embodiment of the application, in the small program page refreshing process, only the simulator working thread needs to be reloaded, other processes are not affected, and the small program page refreshing efficiency is improved. Moreover, the small program interface is placed in the main process of the simulator, and reconstruction is not needed, namely, the research and development workload of a small program development tool is not increased.
The present embodiment specifically describes a synchronous communication process of the simulator worker thread on the basis of the above embodiments. Fig. 4 a-4 d are timing diagrams of synchronous communications provided according to embodiments of the present application, respectively.
Referring to FIG. 4a, the simulator worker thread and simulator host process may communicate synchronously by: the simulator working thread can send a function call instruction to a simulator main process, wherein the function call instruction can comprise a function name, a function parameter and a unique function call identifier (also called as a unique synchronous communication identifier); the simulator main process executes the function to be called and writes an execution result into the shared memory; writing the unique function calling identifier into the shared memory as a wake-up identifier; before the simulator working thread enters the waiting state, the execution result is written into the shared memory when the condition that the awakening identifier exists in the shared memory is detected, and the simulator working thread can directly read the execution result from the shared memory without entering the waiting state.
Referring to FIG. 4b, the simulator worker thread and simulator host process may also communicate synchronously by: the simulator working thread can send a function calling instruction to the simulator main process; the simulator working thread detects whether the execution result in the shared memory is written in, and enters a waiting state under the condition of incomplete writing; the simulator main process executes the function to be called and writes an execution result into the shared memory; writing the unique function calling identifier into the shared memory as a wake-up identifier; the simulator main process also wakes up the simulator working thread after completing the writing; and the awakened simulator working thread reads an execution result from the shared memory.
Referring to FIG. 4c, the simulator worker thread and simulator host process may also communicate synchronously by: the simulator working thread can send a function calling instruction to the simulator main process; the simulator working thread detects whether the execution result in the shared memory is written in, and enters a waiting state under the condition of incomplete writing; the simulator main process executes the function to be called and writes an execution result into the shared memory; writing the unique function calling identifier into the shared memory as a wake-up identifier; and after the working thread of the simulator is in a waiting state for a certain time (such as after waiting for 5 ms), re-detecting whether the execution result in the shared memory is written into, and under the condition of finishing writing, finishing waiting. After the waiting is finished, the execution result can be read from the shared memory.
Referring to FIG. 4d, the simulator worker thread may also communicate synchronously with the simulator main process by: the simulator working thread can send a function calling instruction to the simulator main process; the simulator main process executes a function to be called; the simulator working thread detects whether the execution result in the shared memory is written in, and enters a waiting state under the condition of incomplete writing; after entering a waiting state for a certain time (such as after waiting for 5 ms), the working thread of the simulator detects whether the execution result in the shared memory is written into the shared memory again, and continues to wait under the condition that the writing is not finished; the simulator main process writes the execution result into the shared memory, and also writes the unique function calling identifier into the shared memory as a wake-up identifier; and after the writing is finished, the simulator main process wakes up the simulator working thread. The reason why the waiting time of the simulator worker thread is long may be that the execution time is too long after the simulator main process receives the asynchronous event. It should be noted that, if the synchronous communication time length exceeds the maximum communication time length threshold, for example, 3s, the synchronous communication is ended, and the timeout error notification is performed.
According to the technical scheme of the embodiment of the application, the state of the working thread of the simulator is controlled, so that the problem of deadlock abnormity of the working thread of the simulator and the main process of the simulator in the synchronous communication process can be avoided.
Fig. 5 is a schematic structural diagram of an applet simulation apparatus according to an embodiment of the present application. Referring to fig. 5, an applet simulation apparatus 500 provided in an embodiment of the present application may include:
the simulator main process 501 is used for sending a reload instruction to a simulator working thread under the condition of updating the applet;
a simulator worker thread 502 for reloading updated applet data and sending the updated applet data to the simulator main process;
the simulator main process 501 is further configured to simulate the applet running according to the updated applet data.
In an optional implementation manner, the simulator main process 501 is specifically configured to execute a function to be called to obtain an execution result in response to a function call instruction sent by the simulator working thread according to updated applet data, and write the execution result into a shared memory;
the simulator worker thread 502 is specifically configured to wait when it is detected that the execution result in the shared memory is not written into the shared memory;
the simulator main process 501 is further configured to wake up the simulator worker thread when it is detected that the execution result in the shared memory is written into the shared memory, and read the execution result from the shared memory by the simulator worker thread.
In an optional implementation manner, the simulator main process 501 is specifically configured to execute a function to be called to obtain an execution result in response to a function call instruction sent by the simulator working thread according to updated applet data, and write the execution result into a shared memory;
the simulator worker thread 502 is specifically configured to read the execution result from the shared memory when it is detected that the execution result in the shared memory is written into the shared memory.
In an optional implementation manner, the simulator main process 501 is further configured to write a wake up flag into the shared memory; the wake-up identifier is used for representing whether the execution result in the shared memory is written in.
In an optional implementation manner, the function call instruction includes a function call identifier, and the function call identifier is unique and is used to write the function call identifier into the shared memory as the wake-up identifier.
In an alternative embodiment, the simulator host process 501 is further configured to update the applet page according to the updated applet data through the rendering process.
In an optional embodiment, the simulator main process 501 is further configured to preload an applet interface during the start-up process of the simulator, so as to prepare for the applet to be simulated.
According to the technical scheme, under the condition of updating the applet, the simulator working thread only needs to be reloaded, so that the applet updating efficiency in the simulation process is improved, and the applet development efficiency is improved. Synchronous communication of the working threads of the simulator can be supported through the cooperation of the shared memory and the atomic operation; and deadlock abnormity in the synchronous communication process can be avoided. In addition, the problem of insufficient shared memory can be solved through data fragmentation sending.
According to an embodiment of the present application, an electronic device and a readable storage medium are also provided.
Fig. 6 is a block diagram of an electronic device according to an applet simulation method according to an embodiment of the application. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit implementations of the present application that are described and/or claimed herein.
As shown in fig. 6, the electronic apparatus includes: one or more processors 601, memory 602, and interfaces for connecting the various components, including a high-speed interface and a low-speed interface. The various components are interconnected using different buses and may be mounted on a common motherboard or in other manners as desired. The processor may process instructions for execution within the electronic device, including instructions stored in or on the memory to display graphical information of a GUI on an external input/output apparatus (such as a display device coupled to the interface). In other embodiments, multiple processors and/or multiple buses may be used, along with multiple memories and multiple memories, as desired. Also, multiple electronic devices may be connected, with each device providing portions of the necessary operations (e.g., as a server array, a group of blade servers, or a multi-processor system). In fig. 6, one processor 601 is taken as an example.
The memory 602 is a non-transitory computer readable storage medium as provided herein. Wherein the memory stores instructions executable by at least one processor to cause the at least one processor to perform the applet simulation method provided herein. The non-transitory computer-readable storage medium of the present application stores computer instructions for causing a computer to perform the applet simulation method provided herein.
The memory 602, as a non-transitory computer readable storage medium, may be used to store non-transitory software programs, non-transitory computer executable programs, and modules, such as program instructions/modules (e.g., the simulator main process 501 and the simulator worker thread 502 shown in fig. 5) corresponding to the applet simulation method in the embodiments of the present application. The processor 601 executes various functional applications of the server and applet simulation, i.e. implementing the applet simulation method in the above-described method embodiments, by running non-transitory software programs, instructions and modules stored in the memory 602.
The memory 602 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created in accordance with the use of the applet simulation electronic apparatus, and the like. Further, the memory 602 may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, the memory 602 optionally includes memory located remotely from the processor 601, and these remote memories may be connected to the applet emulation electronics via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The electronic device of the applet simulation method may further include: an input device 603 and an output device 604. The processor 601, the memory 602, the input device 603 and the output device 604 may be connected by a bus or other means, and fig. 6 illustrates the connection by a bus as an example.
The input device 603 may receive input numeric or character information and generate key signal inputs related to user settings and function control of the applet emulating electronic device, such as a touch screen, keypad, mouse, track pad, touch pad, pointer stick, one or more mouse buttons, track ball, joystick, etc. input devices. The output devices 604 may include a display device, auxiliary lighting devices (e.g., LEDs), and tactile feedback devices (e.g., vibrating motors), among others. The display device may include, but is not limited to, a Liquid Crystal Display (LCD), a Light Emitting Diode (LED) display, and a plasma display. In some implementations, the display device can be a touch screen.
Various implementations of the systems and techniques described here can be realized in digital electronic circuitry, integrated circuitry, application specific ASICs (application specific integrated circuits), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
These computer programs (also known as programs, software applications, or code) include machine instructions for a programmable processor, and may be implemented using high-level procedural and/or object-oriented programming languages, and/or assembly/machine languages. As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, apparatus, and/or device (e.g., magnetic discs, optical disks, memory, Programmable Logic Devices (PLDs)) used to provide machine instructions and/or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal used to provide machine instructions and/or data to a programmable processor.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), Wide Area Networks (WANs), blockchain networks, and the internet.
The computer system may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other.
According to the technical scheme, under the condition of updating the applet, the simulator working thread only needs to be reloaded, so that the applet updating efficiency in the simulation process is improved, and the applet development efficiency is improved. Synchronous communication of the working threads of the simulator can be supported through the cooperation of the shared memory and the atomic operation; and deadlock abnormity in the synchronous communication process can be avoided. In addition, the problem of insufficient shared memory can be solved through data fragmentation sending.
The above-described embodiments should not be construed as limiting the scope of the present application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may be made in accordance with design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims (16)

1. An applet simulation method comprising:
under the condition of updating the small program, the simulator main process sends a reloading instruction to the simulator working thread;
reloading the simulator working thread to obtain updated small program data, and sending the updated small program data to the simulator main process;
and the simulator main process simulates the small program to run according to the updated small program data.
2. The method of claim 1, wherein the simulator host process simulates applet execution based on the updated applet data, comprising:
the simulator main process responds to a function call instruction sent by the simulator working thread according to the updated applet data, executes a function to be called to obtain an execution result, and writes the execution result into the shared memory;
the simulator working thread waits when detecting that the execution result in the shared memory is not written into;
and when detecting that the execution result in the shared memory is written, the simulator main process wakes up the simulator working thread, and the simulator working thread reads the execution result from the shared memory.
3. The method of claim 1, wherein the simulator host process simulates applet execution based on the updated applet data, comprising:
the simulator main process responds to a function call instruction sent by the simulator working thread according to the updated applet data, executes a function to be called to obtain an execution result, and writes the execution result into the shared memory;
and the simulator working thread reads the execution result from the shared memory when detecting that the execution result in the shared memory is written into the shared memory.
4. The method of claim 2 or 3, after writing the execution result to the shared memory, the method further comprising:
the simulator main process writes a wake-up identifier into the shared memory; the wake-up identifier is used for representing whether the execution result in the shared memory is written in.
5. The method according to claim 4, wherein the function call instruction includes a function call identifier, and the function call identifier is unique and is used to write the function call identifier as the wake-up identifier into the shared memory.
6. The method of claim 1, wherein the simulator host process simulates applet execution based on the updated applet data, comprising:
and the simulator main process updates the applet page according to the updated applet data through the rendering process.
7. The method of claim 1, further comprising:
and in the starting process of the simulator, the simulator main process also preloads an applet interface for calling the applet to be simulated.
8. An applet simulation apparatus comprising:
the simulator main process is used for sending a reloading instruction to the simulator working thread under the condition of updating the applet;
the simulator working thread is used for reloading to obtain updated applet data and sending the updated applet data to the simulator main process;
and the simulator main process is also used for simulating the small program to run according to the updated small program data.
9. The apparatus of claim 8, wherein,
the simulator main process is specifically used for responding to a function call instruction sent by the simulator working thread according to the updated applet data, executing a function to be called to obtain an execution result, and writing the execution result into the shared memory;
the simulator working thread is specifically used for entering waiting under the condition that the execution result in the shared memory is not written into the shared memory;
the simulator main process is further specifically configured to wake up the simulator worker thread when it is detected that the execution result in the shared memory is written, and read the execution result from the shared memory by the simulator worker thread.
10. The apparatus of claim 8, wherein,
the simulator main process is specifically used for responding to a function call instruction sent by the simulator working thread according to the updated applet data, executing a function to be called to obtain an execution result, and writing the execution result into the shared memory;
the simulator worker thread is specifically configured to read the execution result from the shared memory when it is detected that the execution result in the shared memory is written into the shared memory.
11. The apparatus of claim 9 or 10,
the simulator main process is also used for writing a wake-up identifier into the shared memory; the wake-up identifier is used for representing whether the execution result in the shared memory is written in.
12. The apparatus according to claim 11, wherein the function call instruction includes a function call identifier, and the function call identifier is unique and configured to write the function call identifier as the wake-up identifier into the shared memory.
13. The apparatus of claim 8, wherein,
the simulator main process is also used for updating the applet page according to the updated applet data through the rendering process.
14. The apparatus of claim 8, wherein,
the simulator main process is also used for preloading an applet interface in the starting process of the simulator so as to be called by the applet to be simulated.
15. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-7.
16. A non-transitory computer readable storage medium having stored thereon computer instructions for causing the computer to perform the method of any one of claims 1-7.
CN202011131957.1A 2020-10-21 2020-10-21 Applet simulation method, apparatus, electronic device, and computer-readable storage medium Active CN112286656B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011131957.1A CN112286656B (en) 2020-10-21 2020-10-21 Applet simulation method, apparatus, electronic device, and computer-readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011131957.1A CN112286656B (en) 2020-10-21 2020-10-21 Applet simulation method, apparatus, electronic device, and computer-readable storage medium

Publications (2)

Publication Number Publication Date
CN112286656A true CN112286656A (en) 2021-01-29
CN112286656B CN112286656B (en) 2023-08-29

Family

ID=74424444

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011131957.1A Active CN112286656B (en) 2020-10-21 2020-10-21 Applet simulation method, apparatus, electronic device, and computer-readable storage medium

Country Status (1)

Country Link
CN (1) CN112286656B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113064748A (en) * 2021-04-08 2021-07-02 中国第一汽车股份有限公司 Process succession method, device, electronic equipment and storage medium
CN113760762A (en) * 2021-09-08 2021-12-07 北京房江湖科技有限公司 Method for simulating operating environment of applet, electronic device and storage medium
CN113783966A (en) * 2021-09-23 2021-12-10 北京火山引擎科技有限公司 Data transmission method and device, readable medium and electronic equipment
WO2022237098A1 (en) * 2021-05-14 2022-11-17 统信软件技术有限公司 Heterogeneous program execution method and apparatus, and computing device and readable storage medium
CN116661882A (en) * 2022-11-22 2023-08-29 荣耀终端有限公司 Method for preloading applet, electronic device and storage medium

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040088527A1 (en) * 2002-10-31 2004-05-06 Huppenthal Jon M. Multi-adaptive processing systems and techniques for enhancing parallelism and performance of computational functions
US20120096441A1 (en) * 2005-10-21 2012-04-19 Gregory Edward Warwick Law System and method for debugging of computer programs
CN105718305A (en) * 2016-03-15 2016-06-29 南京南瑞继保电气有限公司 Simulation task parallel scheduling method based on progress
JP2017215933A (en) * 2016-05-26 2017-12-07 富士通株式会社 Information processing device, and load distribution control method
CN109144559A (en) * 2018-09-26 2019-01-04 深圳壹账通智能科技有限公司 A kind of method for pushing and server of updated data package
CN110413386A (en) * 2019-06-27 2019-11-05 深圳市富途网络科技有限公司 Multiprocessing method, apparatus, terminal device and computer readable storage medium
US20190370033A1 (en) * 2018-06-03 2019-12-05 Apple Inc. Multi-process model for cross-platform applications
CN110928791A (en) * 2019-11-27 2020-03-27 腾讯科技(深圳)有限公司 Program testing method, program testing device, computer equipment and storage medium
CN111046062A (en) * 2019-12-16 2020-04-21 北京智游网安科技有限公司 Applet data acquisition method, intelligent terminal and storage medium
CN111475259A (en) * 2020-04-02 2020-07-31 北京百度网讯科技有限公司 Applet loading method and device and electronic equipment

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040088527A1 (en) * 2002-10-31 2004-05-06 Huppenthal Jon M. Multi-adaptive processing systems and techniques for enhancing parallelism and performance of computational functions
US20120096441A1 (en) * 2005-10-21 2012-04-19 Gregory Edward Warwick Law System and method for debugging of computer programs
CN105718305A (en) * 2016-03-15 2016-06-29 南京南瑞继保电气有限公司 Simulation task parallel scheduling method based on progress
JP2017215933A (en) * 2016-05-26 2017-12-07 富士通株式会社 Information processing device, and load distribution control method
US20190370033A1 (en) * 2018-06-03 2019-12-05 Apple Inc. Multi-process model for cross-platform applications
CN109144559A (en) * 2018-09-26 2019-01-04 深圳壹账通智能科技有限公司 A kind of method for pushing and server of updated data package
CN110413386A (en) * 2019-06-27 2019-11-05 深圳市富途网络科技有限公司 Multiprocessing method, apparatus, terminal device and computer readable storage medium
CN110928791A (en) * 2019-11-27 2020-03-27 腾讯科技(深圳)有限公司 Program testing method, program testing device, computer equipment and storage medium
CN111046062A (en) * 2019-12-16 2020-04-21 北京智游网安科技有限公司 Applet data acquisition method, intelligent terminal and storage medium
CN111475259A (en) * 2020-04-02 2020-07-31 北京百度网讯科技有限公司 Applet loading method and device and electronic equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
许建卫;陈明宇;刘涛;杨伟;郑规;孙凝晖;: "一种基于超步执行的并行模拟平台研究与实现", 系统仿真学报, no. 15, pages 4647 - 4660 *

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113064748A (en) * 2021-04-08 2021-07-02 中国第一汽车股份有限公司 Process succession method, device, electronic equipment and storage medium
WO2022237098A1 (en) * 2021-05-14 2022-11-17 统信软件技术有限公司 Heterogeneous program execution method and apparatus, and computing device and readable storage medium
CN113760762A (en) * 2021-09-08 2021-12-07 北京房江湖科技有限公司 Method for simulating operating environment of applet, electronic device and storage medium
CN113760762B (en) * 2021-09-08 2024-03-08 贝壳找房(北京)科技有限公司 Method for simulating operating environment of applet, electronic device and storage medium
CN113783966A (en) * 2021-09-23 2021-12-10 北京火山引擎科技有限公司 Data transmission method and device, readable medium and electronic equipment
CN116661882A (en) * 2022-11-22 2023-08-29 荣耀终端有限公司 Method for preloading applet, electronic device and storage medium
CN116661882B (en) * 2022-11-22 2024-04-16 荣耀终端有限公司 Method for preloading applet, electronic device and storage medium

Also Published As

Publication number Publication date
CN112286656B (en) 2023-08-29

Similar Documents

Publication Publication Date Title
CN112286656B (en) Applet simulation method, apparatus, electronic device, and computer-readable storage medium
JP7167222B2 (en) APPLET DATA ACQUISITION METHOD, APPARATUS, DEVICE, AND STORAGE MEDIUM
CN105765534A (en) Virtual computing systems and methods
CN102667730A (en) Design time debugging
US20210191780A1 (en) Method and apparatus for processing development machine operation task, device and storage medium
CN111767090A (en) Method and device for starting small program, electronic equipment and storage medium
JP7072103B2 (en) Blockchain smart contract implementation method, equipment, equipment and media
EP4209894A1 (en) Cloud code development system, method, and apparatus, device, and storage medium
US8543975B2 (en) Behavior-first event programming model
CN111459813B (en) Test processing method and device
CN111782181A (en) Code generation method and device, electronic equipment and storage medium
CN112506854A (en) Method, device, equipment and medium for storing page template file and generating page
KR102451678B1 (en) Method and apparatus for data processing based on smart contract, device and storage medium
US10305976B2 (en) Method and apparatus for dynamically offloading execution of machine code in an application to a virtual machine
CN111563253B (en) Intelligent contract operation method, device, equipment and storage medium
CN112214416B (en) Method, device, electronic equipment and storage medium for debugging small program
JP2021119479A (en) Method for starting application program, device, equipment, and storage medium
US20140250251A1 (en) Automatically and transparently preserving testing state across sessions
CN111782218A (en) Applet processing method, device, equipment and storage medium
CN112579460B (en) Multi-level debugging method based on multi-core embedded system
CN117813586A (en) Hot reloading running applications with unsaved source code changes
CN114028801A (en) User input method, device, equipment and storage medium based on cloud
CN112379945A (en) Method, device, equipment and storage medium for running application
KR20210049725A (en) Instruction executing method and apparatus, electronic device, and computer-readable storage medium
CN113051122A (en) Performance data acquisition method, performance data acquisition device, electronic equipment and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant