Looking for breakthrough ideas for innovation challenges? Try Patsnap Eureka!

JS-based execution context acquisition method and related device

An execution context and acquisition method technology, applied in the web front-end field, can solve problems such as inability to obtain the execution context

Pending Publication Date: 2021-04-30
上海微盟企业发展有限公司
View PDF0 Cites 0 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

After the asynchronous event is triggered, when the latter part of the asynchronous code is executed, the correct execution context may not be obtained

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • JS-based execution context acquisition method and related device
  • JS-based execution context acquisition method and related device
  • JS-based execution context acquisition method and related device

Examples

Experimental program
Comparison scheme
Effect test

Embodiment Construction

[0053] The core of the present invention is to provide a JS-based execution context acquisition method. In the prior art, since the JS engine is a single-threaded mechanism, when executing asynchronous code, after the previous part of the current asynchronous code is executed, the execution stack will be destroyed, and other codes will be executed. After the asynchronous event is triggered, when the latter part of the asynchronous code is executed, the correct execution context may not be obtained.

[0054] And a kind of execution context acquisition method based on JS provided by the present invention, comprises intercepting asynchronous code; After intercepting asynchronous code, calls wrapping function, preserves current execution context based on the internal variable in wrapping function, returns an internal function simultaneously; After calling the wrapped function, execute the asynchronous code; when an asynchronous event of the asynchronous code is triggered, push the...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

PUM

No PUM Login to View More

Abstract

The invention discloses a JS-based execution context acquisition method. The method comprises the following steps: intercepting an asynchronous code; after the asynchronous code is intercepted, calling a wrapping function, storing a current execution context based on an internal variable in the wrapping function, and returning an internal function; after the package function is called, executing the asynchronous code; when an asynchronous event of the asynchronous code is triggered, pressing an internal function into an execution stack, and reading an internal variable through the internal function to form a closure; reading the saved execution context based on the closure. By intercepting the asynchronous code, storing a current execution context through a wrapping function before executing the asynchronous code, and then executing the asynchronous code, when the asynchronous event is triggered, the internal function is used for reading an internal variable for storing an execution context to form a closed packet, and based on the closed packet, it can be guaranteed that a correct context is read. The invention further provides a device, equipment and a storage medium, which also have the above beneficial effects.

Description

technical field [0001] The present invention relates to the field of web front-end technologies, in particular to a JS-based execution context acquisition method, a JS-based execution context acquisition device, a JS-based execution context acquisition device, and a computer-readable storage medium. Background technique [0002] With the development of science and technology and the progress of society, computers and networks are more and more widely used in people's daily life. And JS (JavaScript) is a lightweight, interpreted or just-in-time compiled high-level programming language with function priority, and it is famous as a scripting language for developing Web pages. [0003] And because the JS engine is a single-threaded mechanism, when executing asynchronous code, after the previous part of the current asynchronous code is executed, the execution stack will be destroyed, and other codes will be executed. After the asynchronous event is triggered, when the latter par...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

Application Information

Patent Timeline
no application Login to View More
Patent Type & Authority Applications(China)
IPC IPC(8): G06F8/30G06F8/41
CPCG06F8/315G06F8/43Y02D10/00
Inventor 张勇
Owner 上海微盟企业发展有限公司
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Patsnap Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Patsnap Eureka Blog
Learn More
PatSnap group products