Processing method and device for achieving synchronous call based on asynchronous call

A technique for asynchronously calling and processing methods, applied in the computer field

Active Publication Date: 2017-12-15
WUHAN DOUYU NETWORK TECH CO LTD
View PDF5 Cites 8 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

[0005] The present invention provides a processing method and device for realizing synchronous call based on asynchr

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
  • Processing method and device for achieving synchronous call based on asynchronous call
  • Processing method and device for achieving synchronous call based on asynchronous call
  • Processing method and device for achieving synchronous call based on asynchronous call

Examples

Experimental program
Comparison scheme
Effect test

Embodiment 1

[0052] This embodiment provides a processing method for implementing synchronous calls based on asynchronous calls, please refer to figure 1 , the method includes:

[0053] Step S101: Obtain a preset first function for asynchronous calling, the parameters of the first function include a first callback function;

[0054] Step S102: generating a second function for synchronous calling, wherein the parameters of the second function include a second callback function and time, and there is a corresponding relationship between the second callback function and the first callback function;

[0055] Step S103: according to the corresponding relationship, call the first function in the second function, and call the first callback function asynchronously through the first function;

[0056] Step S104: If the waiting time for obtaining the execution result of the first callback function is less than the value of the time parameter, call the second callback function synchronously through...

Embodiment 2

[0099] An embodiment of the present invention provides a processing device for implementing synchronous calls based on asynchronous calls. Please refer to figure 2 , the device consists of:

[0100] An acquisition module 201, configured to acquire a preset first function for asynchronous invocation, where the parameters of the first function include a first callback function;

[0101] A generation module 202, configured to generate a second function for synchronous calling according to parameters of the first function, wherein the parameters of the second function include a second callback function and time;

[0102] An asynchronous calling module 203, configured to construct a correspondence between the second callback function and the first callback function, and according to the correspondence, call the first function in the second function, through the first callback function A function calls the first callback function asynchronously;

[0103] A synchronous calling mod...

Embodiment 3

[0112] An embodiment of the present invention provides a computer-readable storage medium 300, on which a computer program 311 is stored. When the program is executed by a processor, the following steps are implemented:

[0113] Obtaining a preset first function for asynchronous invocation, where parameters of the first function include a first callback function;

[0114] generating a second function for synchronous calling according to parameters of the first function, wherein the parameters of the second function include a second callback function and time;

[0115] constructing a correspondence between the second callback function and the first callback function, and calling the first function in the second function according to the correspondence, and calling the first callback asynchronously through the first function a callback function;

[0116] If the waiting time for obtaining the execution result of the first callback function is less than the value of the time para...

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 processing method and device for achieving a synchronous call based on an asynchronous call. The method includes the steps of obtaining a first function preset for the asynchronous call, wherein the parameters of the first function includes a first callback function; generating a second function used for synchronous call according to the parameters of the first function, wherein the parameters of the second function include a second callback function and time; constructing the corresponding relation between the second callback function and the first callback function, calling the first function in the second function according to the corresponding relation, and calling the first callback function asynchronously through the first function; if the wait time for obtaining the execution results of the first callback function is less than the value of the time parameter, calling the second callback function synchronously through the second function. According to the processing method and device for achieving the synchronous call based on the asynchronous call, the technical problem of security and synchronization caused easily by multithreading through using the asynchronous calling method in the existing technology can be solved.

Description

technical field [0001] The invention relates to the field of computer technology, in particular to a processing method and device for realizing synchronous calling based on asynchronous calling. Background technique [0002] In the process of processing tasks or transactions, the computer can use synchronous calls or asynchronous calls, and asynchronous calls can be widely used by using multi-threading technology, and most of them are used for relatively time-consuming and easy-to-block transactions. Through asynchronous calls The transaction can be handed over to a new thread to complete without blocking the current thread, and when the transaction is completed, it will be notified by way of callback (callback). [0003] However, asynchronous calls involve sharing code and shared data between different threads, and need to set various status flags to avoid conflicts, so the implementation is more complicated, and problems are prone to occur when using asynchronous calls to ...

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
IPC IPC(8): G06F9/52
CPCG06F9/52
Inventor 李从章张文明陈少杰
Owner WUHAN DOUYU NETWORK TECH CO LTD
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Try Eureka
PatSnap group products