Detailed Description
The embodiment of the specification provides an execution method, an execution device and a storage medium for an aggregate event stream.
In order to make the technical solutions in the present specification better understood by those skilled in the art, the technical solutions in the embodiments of the present specification will be clearly and completely described below with reference to the drawings in the embodiments of the present specification, and it is obvious that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, shall fall within the scope of the present application.
As shown in fig. 1, fig. 1 is a flow chart of an execution method of an aggregate event stream according to an embodiment of the present disclosure, which is applied to an aggregate event stream including a plurality of events, and the method includes:
S101, acquiring an aggregate event stream comprising a plurality of events.
The types of events in the aggregate event stream include native events or simulated events. The native event is an event generated by the browser in response to an operation (such as clicking, selecting or inputting operation) of a user. Meanwhile, in part of the operation, an accompanying event corresponding to the native event may also occur.
For example, in a browser interface, a user clicks on a selectable box in the interface. This click triggers a "click event", and if the selectable box is an element that can be changed, for example, after the user clicks on the selectable box, the value or shape within the box changes (e.g., the shape within the box changes from null to a "v" or a "x"), then a "change event" that accompanies the click also occurs. The event may be regarded as an incident to the native event.
It is easy to understand that not every native event will have an accompanying event, but every accompanying event will have a corresponding native event, and logically, execution of the native event should always precede the corresponding accompanying event.
In practical application, the types of browsers used by the front end are more and more, and the execution environments of different wave devices for the accompanying events are different. In this case, in order to adapt to execution environments of more different browsers, the development end generally converts the accompanying event into a corresponding simulation event, and interfaces or execution parameters adapted to different browsers are added in the simulation event to adapt to the browsers of different environments.
That is, in the embodiment of the present specification, the simulation events are in one-to-one correspondence with the accompanying events. Accordingly, similar to the accompanying events, not every native event will have a corresponding simulated event, but every simulated event will have a native event corresponding to it, and execution of the native event should always precede the corresponding simulated event.
Fig. 2 is a schematic diagram illustrating generation of a native event and a simulated event according to an embodiment of the present disclosure. In the diagram, a user clicks a selectable box to generate a "click" native event, meanwhile, elements in the selectable box are changed, and then a corresponding "change" accompanying event is generated, at this time, by packaging the accompanying event, a "change" simulation event which can be executed under various browsers is generated, and the "click" native event and the "change" simulation event are pressed into an aggregate event stream in sequence to wait for execution.
At this time, in the aggregate event stream, the previous native event may also be referred to as a pre-event, and the subsequent simulation event may also be referred to as a post-event.
S103, circularly updating the aggregation event stream. The specific updating mode is as follows:
S1031, obtaining a first event in the aggregate event stream. That is, the first event is always fetched from the top of the aggregate event stream for execution each time.
S1033, when the acquired type of the first event is a simulation event, determining whether the original event corresponding to the simulation event is blocked or not.
It should be noted that, in this process, if the type of the first event obtained is a native event, it may be executed by default. When the first event is of the type of a native event, the native event will not be executed if it is marked as a blocking event.
S1035, if the original event is blocked, stopping executing the first event, otherwise, executing the first event.
For example, in the previous example, when executing the "change" simulation event, if the corresponding "click" native event is blocked, the execution of the "change" simulation event is terminated, otherwise, the execution of the "change" simulation event is continued, so that the "change" simulation event and the "click" native event are logically consistent.
S1037, removing the first event in the aggregation event stream, and generating an updated aggregation event stream.
After the aggregate event stream is updated, the process will repeat to steps S1031 to S1037 to cycle through all events in the aggregate event stream.
S105, when the first event in the updated aggregate event stream is empty, determining that the aggregate event stream is executed.
The method comprises the steps of obtaining a first event in an aggregate event stream, determining whether a primary event corresponding to a simulation event is blocked or not when the obtained type of the first event is the simulation event, terminating execution of the first event if the primary event is blocked, otherwise, executing the first event, removing the first event in the aggregate event stream to generate an updated aggregate event stream, and determining that the aggregate event stream is executed when the first event in the updated aggregate event stream is empty. Therefore, when the aggregate event stream is traversed and executed, when the front event is blocked, the corresponding simulation event is not executed any more, unexpected event triggering is avoided, and the flow of the original event is simulated more accurately.
In one embodiment, for determining the native event corresponding to the simulated event in S1033 in the foregoing step, the determination may be made according to a push manner of the event in the aggregate event stream.
For example, if the simulated event and the corresponding native event are always pressed into the event stream in a tight sequence, the previous event corresponding to the simulated event in the event stream can be directly determined as the native event corresponding to the simulated event.
For another example, if the simulated event and the corresponding native event are not in close proximity, but there are other events in between. The native event it references may be indicated in the simulated event by referencing the value of the variable when the simulated event is generated. For example, the native event referenced by the simulated event is indicated by the reference variable "NATIVEEVENT" contained in the simulated event. For example, by assigning "NATIVEEVENT =click" to indicate that the native event referenced by the simulation event is a native click event, or by assigning "NATIVEEVENT =1" to indicate that the native event referenced by the simulation event is a native event 1, the corresponding relationship determination of the native event is accurately achieved by determining the native event corresponding to the simulation event according to the value of the reference variable.
In one embodiment, for determining whether the native event corresponding to the simulated event is blocked in S1033 in the foregoing step, the following manner may be adopted to determine:
For example, an instruction called by a native event corresponding to the simulated event may be obtained, and when the called instruction meets a condition, it is determined that the native event corresponding to the simulated event is blocked. In practical applications, a native event is sometimes called by a developer using several instructions. After being called, some instructions may appear that the development end hopes that the native event is blocked, or some instructions that after being called, the environment of the native event is changed and blocked.
That is, a set of blocking instructions may be preset, where the set includes related blocking instructions, and when an instruction called for a native event belongs to the set, it may be determined that the native event corresponding to the simulated event is blocked. For example, when a native event is called by the call instruction "preventDefault", if the instruction belongs to a predefined set of blocking instructions, the native event can be considered to be blocked.
Or whether the native event corresponding to the simulation event contains a blocking mark can be determined to determine whether the native event corresponding to the simulation event is blocked. In a native event, a specific blocking flag may be set, for example, "default=0" may be used to flag that the native event is not blocked, and "default=1" may be used to flag that the native event has been blocked and is no longer executed.
In one embodiment, the simulation events in the aggregate event stream are pre-generated based on the following manner that a primary event corresponding to an operation is generated in response to the operation of a user, the element type of a node of the primary event is detected, and when the element type meets a preset type, the simulation event corresponding to the primary event is created.
The elements herein may be elements in a hypertext markup language (Hyper Text Markup Language HTML). For example, it may be an element in a web page, including, for example, a button in a web page, an input box, text, an image, and so forth. The part of the elements may generate corresponding accompanying events when the part of the elements is clicked by the user operation, so that the part of the elements can be predefined as triggerable elements, and when the element types of the nodes of the original events belong to the triggerable elements, the simulation events corresponding to the original events are created.
In one embodiment, before the element type of the node for detecting the native event in the simulated event is generated, a simulated event template corresponding to the simulated event can be obtained in advance, whether the simulated event template is empty is detected, and when the simulated event template is empty, the creation of the simulated event is terminated.
Templates for simulation events are preconfigured based on differences between browsers. That is, if the execution environment or execution parameters of one companion event are different between different browsers, one simulation event template needs to be configured in advance to generate a simulation event that can be adapted to each browser. However, if the execution environment or the execution parameters of one companion event are the same among different browsers, it is obvious that the companion event need not be created in this case, but may be directly regarded as a simulation event to be pushed into the event stream. At this time, the required simulation event template can be emptied as required because no corresponding simulation event is needed. In this way, the number of creation of invalid simulation events can be reduced, and the simulation efficiency can be improved.
Fig. 3 is a schematic flow chart of generating a simulation event by aggregating event streams according to an embodiment of the present disclosure.
In this schematic, the native event can be encapsulated and pushed into the event stream immediately upon generation. Meanwhile, if it is detected that there is a corresponding accompanying event in the native event, an event template corresponding to the accompanying event may be extracted from the polymerizable event bid farewell.
If the event template is detected to be empty, the accompanying event is not different among the browsers when being executed, and then the corresponding simulation event is not required to be created. The event stream is executed as usual.
If the event template is detected to be not empty, the element type of the node of the original event can be detected, and if the element type is detected to meet the preset type (for example, the input triggerable type comprises a button, a selectable box and the like), a simulation event corresponding to the original event is created, and the simulation event is pressed into an event stream.
The simulation event can be pressed in the event stream in a conventional timely pressing manner, and the original event referenced by the simulation event is only indicated by the reference mark in the simulation event. In the event stream, the simulated event should be placed after the native event to which it refers in order to execute after the native event to which it refers.
Based on the same thought, one or more embodiments of the present disclosure further provide apparatuses and devices corresponding to the above method, as shown in fig. 4 and fig. 5.
In a second aspect, as shown in fig. 4, fig. 4 is a schematic structural diagram of an execution apparatus for aggregating event streams provided in an embodiment of the present disclosure, where the execution apparatus is applied to an aggregate event stream including a plurality of events, and the apparatus includes:
an acquisition module 401 that acquires an aggregate event stream including a plurality of events, wherein the types of the events include native events or simulated events;
The circulation updating module 403 is configured to perform circulation updating on the aggregate event stream by acquiring a first event in the aggregate event stream, determining whether a native event corresponding to a simulated event is blocked when the acquired first event is of a type of the simulated event, and if the native event is blocked, terminating execution of the first event, otherwise, executing the first event;
And a termination module 405, configured to determine that the aggregate event stream is executed when the first event in the updated aggregate event stream is empty.
Optionally, the loop update module 403 obtains a value of a reference variable included in the simulation event, and determines a native event corresponding to the simulation event according to the value of the reference variable.
Optionally, the loop update module 403 obtains an instruction called by a native event corresponding to the simulated event, and determines that the native event corresponding to the simulated event is blocked when the called instruction meets a condition, or determines that the native event corresponding to the simulated event is blocked when the native event corresponding to the simulated event includes a blocking flag.
Optionally, the device further comprises an event generation module 407, responding to the operation of a user, generating a native event corresponding to the operation, detecting the element type of a node of the native event, and creating a simulation event corresponding to the native event when the element type meets a preset type.
Optionally, the event generating module 407 acquires a simulation event template corresponding to the simulation event, detects whether the simulation event template is empty, and terminates creating the simulation event when the simulation event template is empty.
In a third aspect, as shown in fig. 5, fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure, where the device includes:
at least one processor, and
A memory communicatively coupled to the at least one processor, wherein,
The memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of the first aspect.
In a fourth aspect, based on the same considerations, one or more embodiments of the present disclosure further provide a non-volatile computer storage medium corresponding to the above method, storing computer executable instructions that, when read by a computer in the storage medium, cause one or more processors to perform the method according to the first aspect.
In the 90 s of the 20 th century, improvements to one technology could clearly be distinguished as improvements in hardware (e.g., improvements to circuit structures such as diodes, transistors, switches, etc.) or software (improvements to the process flow). However, with the development of technology, many improvements of the current method flows can be regarded as direct improvements of hardware circuit structures. Designers almost always obtain corresponding hardware circuit structures by programming improved method flows into hardware circuits. Therefore, an improvement of a method flow cannot be said to be realized by a hardware entity module. For example, a programmable logic device (Programmable Logic Device, PLD) (e.g., field programmable gate array (Field Programmable GATE ARRAY, FPGA)) is an integrated circuit whose logic functions are determined by user programming of the device. A designer programs to "integrate" a digital system onto a PLD without requiring the chip manufacturer to design and fabricate application-specific integrated circuit chips. Moreover, nowadays, instead of manually manufacturing integrated circuit chips, such programming is mostly implemented with "logic compiler (logic compiler)" software, which is similar to the software compiler used in program development and writing, and the original code before being compiled is also written in a specific programming language, which is called hardware description language (Hardware Description Language, HDL), but HDL is not just one, but a plurality of kinds, such as ABEL(Advanced Boolean Expression Language)、AHDL(Altera Hardware Description Language)、Confluence、CUPL(Cornell University Programming Language)、HDCal、JHDL(Java Hardware Description Language)、Lava、Lola、MyHDL、PALASM、RHDL(Ruby Hardware Description Language), and VHDL (Very-High-SPEED INTEGRATED Circuit Hardware Description Language) and Verilog are currently most commonly used. It will also be apparent to those skilled in the art that a hardware circuit implementing the logic method flow can be readily obtained by merely slightly programming the method flow into an integrated circuit using several of the hardware description languages described above.
The controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer readable medium storing computer readable program code (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, application SPECIFIC INTEGRATED Circuits (ASICs), programmable logic controllers, and embedded microcontrollers, examples of which include, but are not limited to, ARC625D, atmel AT91SAM, microchip PIC18F26K20, and Silicone Labs C8051F320, and the memory controller may also be implemented as part of the control logic of the memory. Those skilled in the art will also appreciate that, in addition to implementing the controller in a pure computer readable program code, it is well possible to implement the same functionality by logically programming the method steps such that the controller is in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers, etc. Such a controller may thus be regarded as a kind of hardware component, and means for performing various functions included therein may also be regarded as structures within the hardware component. Or even means for achieving the various functions may be regarded as either software modules implementing the methods or structures within hardware components.
The system, apparatus, module or unit set forth in the above embodiments may be implemented in particular by a computer chip or entity, or by a product having a certain function. One typical implementation is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
For convenience of description, the above devices are described as being functionally divided into various units, respectively. Of course, the functions of each element may be implemented in one or more software and/or hardware elements when implemented in the present specification.
It will be appreciated by those skilled in the art that the present description may be provided as a method, system, or computer program product. Accordingly, the present specification embodiments may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present description embodiments may take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
The present description is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the specification. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In one typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises an element.
The description may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for apparatus, devices, non-volatile computer storage medium embodiments, the description is relatively simple, as it is substantially similar to method embodiments, with reference to the section of the method embodiments being relevant.
The foregoing describes specific embodiments of the present disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims can be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
The foregoing is merely one or more embodiments of the present description and is not intended to limit the present description. Various modifications and alterations to one or more embodiments of this description will be apparent to those skilled in the art. Any modification, equivalent replacement, improvement, or the like, which is within the spirit and principles of one or more embodiments of the present description, is intended to be included within the scope of the claims of the present description.