CN106371900B - Data processing method and device for realizing asynchronous call - Google Patents
Data processing method and device for realizing asynchronous call Download PDFInfo
- Publication number
- CN106371900B CN106371900B CN201510439850.6A CN201510439850A CN106371900B CN 106371900 B CN106371900 B CN 106371900B CN 201510439850 A CN201510439850 A CN 201510439850A CN 106371900 B CN106371900 B CN 106371900B
- Authority
- CN
- China
- Prior art keywords
- processed
- task
- asynchronous call
- logic controller
- storage structure
- 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.)
- Active
Links
Images
Landscapes
- Mobile Radio Communication Systems (AREA)
- Telephone Function (AREA)
Abstract
The invention discloses a data processing method for realizing asynchronous call, which comprises the following steps: the method comprises the steps that a logic controller creates an asynchronous call chain type storage structure, and the logic controller is created in advance by a system; the logic controller stores a task to be processed comprising at least one callback function in the asynchronous call chain type storage structure, and allocates a working thread to the callback function in the task to be processed respectively to obtain the corresponding relation between the callback function and the working thread; and when the logic controller receives a preset task execution triggering instruction, taking out a task to be processed from the asynchronous call chain type storage structure, and distributing a callback function in the task to be processed to a corresponding working thread for execution. Compared with the prior art, the embodiment of the invention stores the to-be-processed task by using the asynchronous call chain type storage structure, can realize asynchronous call without compiling complex asynchronous codes, and has higher data processing efficiency of the asynchronous call.
Description
Technical Field
The invention relates to the field of data processing, in particular to a data processing method and device for realizing asynchronous calling.
Background
Computers may encounter time-consuming tasks in data processing, and the system may seriously affect program performance if it continues to wait while such task processing code is invoked. For example, after a certain program is started, a file needs to be opened to read data in the file, and then a series of time-consuming tasks of initialization processing are performed according to the data, so that the program of the program main window cannot be executed in time, the program main window cannot be displayed in time, and the user experience is reduced.
At present, the above problems can be easily solved by the implementation of asynchronous calls. Specifically, the whole task of initialization processing can be put into a single thread, and the main thread starts the thread, and then the system does not wait continuously, but starts the thread of the main window program at the same time, so that the main window is displayed instantly. That is, the time-consuming task is handled by asynchronous calls, such that the user experience is enhanced.
However, existing methods for implementing asynchronous calls are complex, for example, a thread library provided in jdk is used, a thread or thread pool is directly used to implement asynchronization of tasks, or a handlethread provided in android sdk is used to implement asynchronization of tasks, these methods all need to write complex asynchronization codes, and the data processing efficiency for implementing asynchronous calls is low.
Disclosure of Invention
In view of this, the present invention provides a data processing method and apparatus for implementing asynchronous call, which can improve the data processing efficiency for implementing asynchronous call.
In one aspect, the present invention provides a data processing method for implementing asynchronous call, where the method includes:
the method comprises the steps that a logic controller creates an asynchronous call chain type storage structure, and the logic controller is created in advance by a system;
the logic controller stores a task to be processed comprising at least one callback function in the asynchronous call chain type storage structure, and allocates a working thread to the callback function in the task to be processed respectively to obtain the corresponding relation between the callback function and the working thread;
and when the logic controller receives a preset task execution triggering instruction, taking out a task to be processed from the asynchronous call chain type storage structure, and distributing a callback function in the task to be processed to a corresponding working thread for execution.
Preferably, the method further comprises:
and when the logic controller learns that the current task to be processed is completed, taking out the next task to be processed of the current task to be processed from the asynchronous call chain type storage structure, and continuously executing the step of distributing the callback function in the task to be processed to the corresponding working thread for execution.
Preferably, the method further comprises:
and when the logic controller learns that the asynchronous call chain type storage structure is empty, deleting the asynchronous call chain type storage structure.
Preferably, the asynchronous call chained storage structure is a queue.
Preferably, the method further comprises:
when the logic controller receives a preset task suspension triggering instruction, suspending a current task to be processed; and when the logic controller receives a preset task recovery triggering instruction, the suspended current task to be processed is recovered and executed.
Preferably, the method further comprises:
the logic controller splices an asynchronous call chain storage structure controlled by the logic controller into an asynchronous call chain storage structure created by a first logic controller, and the first logic controller is created by a system in advance and is different from the logic controller;
the first logic controller controls an asynchronous call chained storage structure of the logic controller.
In another aspect, the present invention further provides a data processing apparatus for implementing asynchronous call, where the apparatus includes:
the creating module is used for creating an asynchronous calling chain type storage structure;
the memory module is used for storing the tasks to be processed including at least one callback function in the asynchronous call chain type memory structure;
the first allocation module is used for allocating a working thread to each callback function in the task to be processed to obtain the corresponding relation between the callback function and the working thread;
the fetching module is used for fetching a task to be processed from the asynchronous call chain type storage structure when a preset task execution triggering instruction is received;
and the second distribution module is used for distributing the callback function in the task to be processed to the corresponding work thread for execution.
Preferably, the apparatus further comprises:
and the triggering module is used for triggering the taking-out module to take out the next task to be processed of the current task to be processed from the asynchronous calling chain type storage structure when the completion of the current task to be processed is known.
Preferably, the apparatus further comprises:
and the deleting module is used for deleting the asynchronous call chain type storage structure when the asynchronous call chain type storage structure is known to be empty.
Preferably, the apparatus further comprises:
the suspension module is used for suspending the current task to be processed when a preset task suspension triggering instruction is received;
and the recovery module is used for recovering the execution of the suspended current task to be processed when a preset task recovery triggering instruction is received.
In the data processing method for realizing asynchronous call, the logic controller firstly creates an asynchronous call chain type storage structure, and the logic controller is created by a system in advance. Secondly, the logic controller stores the tasks to be processed including at least one callback function in the asynchronous call chain type storage structure, and allocates a working thread to the callback function in the tasks to be processed respectively to obtain the corresponding relation between the callback function and the working thread. And when the logic controller receives a preset task execution triggering instruction, taking out a task to be processed from the asynchronous call chain type storage structure, and distributing a callback function in the task to be processed to a corresponding working thread for execution. Compared with the prior art, the invention stores the tasks to be processed by using the asynchronous call chain type storage structure, can realize asynchronous call without compiling complex asynchronous codes, and has higher data processing efficiency of the asynchronous call.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive labor.
FIG. 1 is a flow chart of a data processing method for implementing asynchronous call according to the present invention;
FIG. 2 is a schematic structural diagram of a data processing apparatus for implementing asynchronous call according to the present invention;
fig. 3 is a block diagram of a partial structure of a mobile terminal provided in the present invention.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The data processing method for realizing asynchronous calling provided by the embodiment of the invention is applied to an Android system or an IOS system, focuses on the simplification of the asynchronous function, balances the code development amount and the workload of subsequent maintenance work, simplifies the asynchronous development to the greatest extent, and improves the data processing efficiency for realizing asynchronous calling.
The following describes embodiments of the present invention.
Referring to fig. 1, fig. 1 is a flowchart of a data processing method for implementing asynchronous call provided in this embodiment, which may specifically include:
s101: the logic controller creates an asynchronous call chain storage structure, which is pre-created by the system.
S102: and the logic controller stores the tasks to be processed including at least one callback function in the asynchronous call chain type storage structure, and allocates a working thread to the callback function in the tasks to be processed respectively to obtain the corresponding relation between the callback function and the working thread.
S103: and when the logic controller receives a preset task execution triggering instruction, taking out a task to be processed from the asynchronous call chain type storage structure, and distributing a callback function in the task to be processed to a corresponding working thread for execution.
In S101, a logic controller is first created by a system, where the system may be an Android system, an IOS system, or another system that can implement asynchronization. The logic controller is used for controlling the whole data processing process for realizing asynchronous call and is used as an execution main body for realizing the data processing of the asynchronous call.
In addition, the asynchronous call chained storage structure in S101 is used to implement the asynchronous call storage function. Specifically, the asynchronous call chain storage structure may be a queue, for example, an asynchronous call queue, or may be a linked list.
In S102, the logic controller first determines a task to be processed, and stores the determined task to be processed in a pre-created asynchronous call chain storage structure, for example, in an asynchronous call queue. It is worth noting that when a sequential execution order relationship exists among the tasks to be processed, the logic controller stores the tasks to be processed in the asynchronous call chain type storage structure according to the sequential execution order relationship.
In S102, each to-be-processed task stored in the asynchronous call chain storage structure includes at least one callback function, where the callback function is a function called by a function pointer and is used to implement a function of the to-be-processed task.
In actual operation, in order to implement asynchronous call, the logic controller allocates a work thread to each callback function in the asynchronous call chain storage structure, that is, the logic controller establishes a correspondence between the callback function in the asynchronous call chain storage structure and the work thread. Specifically, in the Android system, the logic controller realizes the function of distributing the callback function to the thread to which the Looper object belongs by binding the callback function with the Looper object.
It should be noted that, since the execution times of different pending tasks in the asynchronous call chain storage structure are different, in order to save resources and fully utilize limited system resources, the callback functions in different pending tasks in this embodiment may be allocated with the same work thread.
In S103, the logic controller detects whether an instruction is received in real time, and when the logic controller receives a preset task execution trigger instruction, takes out one to-be-processed task from the asynchronous call chain storage structure. Specifically, the logic controller fetches a first task to be processed from the asynchronous call chain storage structure.
In practical application, after the logic controller takes out a task to be processed, a callback function included in the task to be processed is determined, and the callback function is distributed to a corresponding working thread for execution. Specifically, the logic controller queries the working threads corresponding to the callback functions in the correspondence between the pre-allocated callback functions and the working threads, and allocates the callback functions to the working threads corresponding to the callback functions for execution, thereby implementing asynchronous call.
In S103, after all callback functions in the current task to be processed are executed in the corresponding work threads, the logic controller learns that the current task to be processed is completed. At this time, the logic controller continues to take out the next task to be processed of the current task to be processed from the asynchronous call chain storage structure, and performs asynchronous processing on the task to be processed. Specifically, the callback function in the task to be processed is allocated to the corresponding work thread for execution.
It is worth noting that when the logic controller learns that the asynchronous call chain storage structure is empty, that is, when all the tasks to be processed in the asynchronous call chain storage structure are completed, the asynchronous call chain storage structure is deleted, and the system resource is released.
In addition, in the embodiment, by storing the to-be-processed task by using the asynchronous call chain storage structure, the functions of suspending and delaying execution of each asynchronous call in the data processing process of the asynchronous call can be realized. Specifically, when the logic controller receives a preset task suspension triggering instruction, the current task to be processed is suspended. That is, the execution of the current pending task is suspended. And when the logic controller receives a preset task recovery triggering instruction, the suspended current task to be processed is recovered and executed. That is, the suspended pending task resumes execution. It can be appreciated that the embodiment can freely control the execution time of the asynchronous call, add more flexibility to the asynchronous implementation, and be compatible with asynchronous components implemented in other ways.
In addition, the application system of this embodiment may include more than one logic controller created in advance, where the logic controller splices the asynchronous call chain storage structure controlled by the logic controller to the asynchronous call chain storage structure created by the first logic controller, and the first logic controller is created in advance by the system and is different from the logic controller; the first logic controller controls an asynchronous call chained storage structure of the logic controller.
For example, the application system of the present embodiment includes more than one logic controller, for example, logic controller a and logic controller B. The logic controller A can splice the asynchronous call chain storage structure controlled by the logic controller A into the asynchronous call chain storage structure created by the logic controller B. That is, the logic controller a hands its task to be processed to the logic controller B for asynchronous processing. The logic controller B splices the asynchronous call chain storage structure of the logic controller A, such as an asynchronous call queue, into an asynchronous operation queue of the logic controller B, so that the logic controller B can call the tasks to be processed from the two asynchronous call queues in a combined mode. It is understood that the combined call processing of the present embodiment can save system resources.
In the data processing method for realizing asynchronous call in the embodiment of the invention, a logic controller firstly creates an asynchronous call chain type storage structure, and the logic controller is pre-created by a system. Secondly, the logic controller stores the tasks to be processed including at least one callback function in the asynchronous call chain type storage structure, and allocates a working thread to the callback function in the tasks to be processed respectively to obtain the corresponding relation between the callback function and the working thread. And when the logic controller receives a preset task execution triggering instruction, taking out a task to be processed from the asynchronous call chain type storage structure, and distributing a callback function in the task to be processed to a corresponding working thread for execution. Compared with the prior art, the embodiment of the invention stores the to-be-processed task by using the asynchronous call chain type storage structure, can realize asynchronous call without compiling complex asynchronous codes, and has higher data processing efficiency of the asynchronous call.
Referring to fig. 2, fig. 2 is a schematic diagram of a data processing apparatus for implementing asynchronous call provided in this embodiment, where the apparatus may include:
a creating module 201, configured to create an asynchronous call chained storage structure;
a storage module 202, configured to store a to-be-processed task including at least one callback function in the asynchronous call chain storage structure;
the first allocation module 203 is configured to allocate a work thread to each callback function in the task to be processed, so as to obtain a corresponding relationship between the callback function and the work thread;
the fetching module 204 is configured to fetch a task to be processed from the asynchronous call chain storage structure when a preset task execution trigger instruction is received;
the second allocating module 205 is configured to allocate the callback function in the task to be processed to the corresponding work thread for execution.
In practical application, the device further comprises:
and the triggering module is used for triggering the taking-out module to take out the next task to be processed of the current task to be processed from the asynchronous calling chain type storage structure when the completion of the current task to be processed is known.
In order to save system resources, the apparatus further comprises:
and the deleting module is used for deleting the asynchronous call chain type storage structure when the asynchronous call chain type storage structure is known to be empty.
In addition, the apparatus further comprises:
the suspension module is used for suspending the current task to be processed when a preset task suspension triggering instruction is received;
and the recovery module is used for recovering the execution of the suspended current task to be processed when a preset task recovery triggering instruction is received.
In the data processing apparatus for implementing asynchronous call in the embodiment of the present invention, the creation module is configured to create an asynchronous call chained storage structure. The storage module is used for storing the tasks to be processed including at least one callback function in the asynchronous call chain storage structure. The first distribution module is used for distributing a working thread for the callback function in the task to be processed respectively to obtain the corresponding relation between the callback function and the working thread. And the taking-out module is used for taking out a task to be processed from the asynchronous call chain storage structure when a preset task execution triggering instruction is received. And the second distribution module is used for distributing the callback function in the task to be processed to the corresponding work thread for execution. Compared with the prior art, the embodiment of the invention stores the to-be-processed task by using the asynchronous call chain type storage structure, can realize asynchronous call without compiling complex asynchronous codes, and has higher data processing efficiency of the asynchronous call.
An embodiment of the present invention further provides a terminal, as shown in fig. 3, for convenience of description, only a part related to the embodiment of the present invention is shown, and details of the specific technology are not disclosed, please refer to the method part of the embodiment of the present invention. The terminal may include any terminal device such as a mobile phone, a tablet computer, a PDA (Personal Digital Assistant), a POS (Point of sales), a vehicle-mounted computer, and take the terminal as the mobile phone for example:
fig. 3 is a block diagram illustrating a partial structure of a mobile phone related to a terminal provided by an embodiment of the present invention. Referring to fig. 3, the cellular phone includes: radio Frequency (RF) circuit 310, memory 320, input unit 330, display unit 340, sensor 350, audio circuit 360, wireless fidelity (WiFi) module 370, processor 380, and power supply 390. Those skilled in the art will appreciate that the handset configuration shown in fig. 3 is not intended to be limiting and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components.
The following describes each component of the mobile phone in detail with reference to fig. 3:
the RF circuit 310 may be used for receiving and transmitting signals during information transmission and reception or during a call, and in particular, receives downlink information of a base station and then processes the received downlink information to the processor 380; in addition, the data for designing uplink is transmitted to the base station. Typically, the RF circuitry includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a Low Noise Amplifier (LNA), a duplexer, and the like. In addition, RF circuit 310 may also communicate with networks and other devices via wireless communication. The wireless communication may use any communication standard or protocol, including but not limited to global system for Mobile communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Messaging Service (SMS), etc.
The memory 320 may be used to store software programs and modules, and the processor 380 executes various functional applications and data processing of the mobile phone by operating the software programs and modules stored in the memory 320. The memory 320 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the cellular phone, and the like. Further, the memory 320 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
The input unit 330 may be used to receive input numeric or character information and generate key signal inputs related to user settings and function control of the cellular phone 300. Specifically, the input unit 330 may include a touch panel 331 and other input devices 332. The touch panel 331, also referred to as a touch screen, can collect touch operations of a user (e.g., operations of the user on the touch panel 331 or near the touch panel 331 using any suitable object or accessory such as a finger, a stylus, etc.) on or near the touch panel 331, and drive the corresponding connection device according to a preset program. Alternatively, the touch panel 331 may include two parts, a touch detection device and a touch controller. The touch detection device detects the touch direction of a user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch sensing device, converts the touch information into touch point coordinates, sends the touch point coordinates to the processor 380, and can receive and execute commands sent by the processor 380. In addition, the touch panel 331 may be implemented in various types, such as a resistive type, a capacitive type, an infrared ray, and a surface acoustic wave. The input unit 330 may include other input devices 332 in addition to the touch panel 331. In particular, other input devices 332 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, and the like.
The display unit 340 may be used to display information input by the user or information provided to the user and various menus of the mobile phone. The display unit 340 may include a display panel 341, and optionally, the display panel 341 may be configured in the form of a Liquid Crystal Display (LCD), an Organic Light-Emitting Diode (OLED), or the like. Further, the touch panel 331 can cover the display panel 341, and when the touch panel 331 detects a touch operation on or near the touch panel 331, the touch panel is transmitted to the processor 380 to determine the type of the touch event, and then the processor 380 provides a corresponding visual output on the display panel 341 according to the type of the touch event. Although in fig. 3, the touch panel 331 and the display panel 341 are two independent components to implement the input and output functions of the mobile phone, in some embodiments, the touch panel 331 and the display panel 341 may be integrated to implement the input and output functions of the mobile phone.
The handset 300 may also include at least one sensor 350, such as a light sensor, motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor that adjusts the brightness of the display panel 341 according to the brightness of ambient light, and a proximity sensor that turns off the display panel 341 and/or the backlight when the mobile phone is moved to the ear. As one of the motion sensors, the accelerometer sensor can detect the magnitude of acceleration in each direction (generally, three axes), can detect the magnitude and direction of gravity when stationary, and can be used for applications of recognizing the posture of a mobile phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer and tapping), and the like; as for other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, and an infrared sensor, which can be configured on the mobile phone, further description is omitted here.
WiFi belongs to short-distance wireless transmission technology, and the mobile phone can help a user to receive and send e-mails, browse webpages, access streaming media and the like through the WiFi module 370, and provides wireless broadband internet access for the user. Although fig. 3 shows the WiFi module 370, it is understood that it does not belong to the essential constitution of the handset 300, and can be omitted entirely as needed within the scope not changing the essence of the invention.
The processor 380 is a control center of the mobile phone, connects various parts of the whole mobile phone by using various interfaces and lines, and performs various functions of the mobile phone and processes data by operating or executing software programs and/or modules stored in the memory 320 and calling data stored in the memory 320, thereby performing overall monitoring of the mobile phone. Optionally, processor 380 may include one or more processing units; preferably, the processor 380 may integrate an application processor, which primarily handles operating systems, user interfaces, applications, etc., and a modem processor, which primarily handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into processor 380.
The handset 300 also includes a power supply 390 (e.g., a battery) for powering the various components, which may preferably be logically coupled to the processor 380 via a power management system to manage charging, discharging, and power consumption via the power management system.
Although not shown, the mobile phone 300 may further include a camera, a bluetooth module, etc., which will not be described herein.
Specifically, in this embodiment, the processor 380 in the terminal loads the executable file corresponding to the process of one or more application programs into the memory 320 according to the following instructions, and the processor 380 runs the application programs stored in the memory 320, thereby implementing various functions:
the method comprises the steps that a logic controller creates an asynchronous call chain type storage structure, and the logic controller is created in advance by a system;
the logic controller stores a task to be processed comprising at least one callback function in the asynchronous call chain type storage structure, and allocates a working thread to the callback function in the task to be processed respectively to obtain the corresponding relation between the callback function and the working thread;
and when the logic controller receives a preset task execution triggering instruction, taking out a task to be processed from the asynchronous call chain type storage structure, and distributing a callback function in the task to be processed to a corresponding working thread for execution.
Preferably, the method further comprises:
and when the logic controller learns that the current task to be processed is completed, taking out the next task to be processed of the current task to be processed from the asynchronous call chain type storage structure, and continuously executing the step of distributing the callback function in the task to be processed to the corresponding working thread for execution.
Preferably, the method further comprises:
and when the logic controller learns that the asynchronous call chain type storage structure is empty, deleting the asynchronous call chain type storage structure.
Preferably, the asynchronous call chained storage structure is a queue.
Preferably, the method further comprises:
when the logic controller receives a preset task suspension triggering instruction, suspending a current task to be processed; and when the logic controller receives a preset task recovery triggering instruction, the suspended current task to be processed is recovered and executed.
Preferably, the method further comprises:
the logic controller splices an asynchronous call chain storage structure controlled by the logic controller into an asynchronous call chain storage structure created by a first logic controller, and the first logic controller is created by a system in advance and is different from the logic controller;
the first logic controller controls an asynchronous call chained storage structure of the logic controller.
For the device embodiments, since they substantially correspond to the method embodiments, reference may be made to the partial description of the method embodiments for relevant points. The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, 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 an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The data processing method and apparatus for implementing asynchronous call provided by the embodiment of the present invention are described in detail above, and a specific example is applied in the text to explain the principle and the implementation of the present invention, and the description of the above embodiment is only used to help understand the method and the core idea of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.
Claims (10)
1. A data processing method for implementing asynchronous calls, the method comprising:
the method comprises the following steps that a logic controller creates an asynchronous call chain type storage structure for realizing an asynchronous call storage function, the asynchronous call chain type storage structure adopts a queue or a chain table, and the logic controller is created in advance by a system;
the logic controller stores a task to be processed comprising at least one callback function in the asynchronous call chain type storage structure, and allocates a working thread to the callback function in the task to be processed respectively to obtain the corresponding relation between the callback function and the working thread;
and when the logic controller receives a preset task execution triggering instruction, taking out a task to be processed from the asynchronous call chain type storage structure, and distributing a callback function in the task to be processed to a corresponding working thread for execution.
2. The method of claim 1, further comprising:
and when the logic controller learns that the current task to be processed is completed, taking out the next task to be processed of the current task to be processed from the asynchronous call chain type storage structure, and continuously executing the step of distributing the callback function in the task to be processed to the corresponding working thread for execution.
3. The method of claim 2, further comprising:
and when the logic controller learns that the asynchronous call chain type storage structure is empty, deleting the asynchronous call chain type storage structure.
4. The method of claim 1, wherein the asynchronous call chained storage structure is a queue.
5. The method of claim 1, further comprising:
when the logic controller receives a preset task suspension triggering instruction, suspending a current task to be processed; and when the logic controller receives a preset task recovery triggering instruction, the suspended current task to be processed is recovered and executed.
6. The method of claim 1, further comprising:
the logic controller splices an asynchronous call chain storage structure controlled by the logic controller into an asynchronous call chain storage structure created by a first logic controller, and the first logic controller is created by a system in advance and is different from the logic controller;
the first logic controller controls an asynchronous call chained storage structure of the logic controller.
7. A data processing apparatus for implementing asynchronous calls, the apparatus comprising:
the system comprises a creating module, a storing module and a processing module, wherein the creating module is used for creating an asynchronous call chain type storage structure for realizing an asynchronous call storage function, and the asynchronous call chain type storage result adopts a queue or a chain table;
the memory module is used for storing the tasks to be processed including at least one callback function in the asynchronous call chain type memory structure;
the first allocation module is used for allocating a working thread to each callback function in the task to be processed to obtain the corresponding relation between the callback function and the working thread;
the fetching module is used for fetching a task to be processed from the asynchronous call chain type storage structure when a preset task execution triggering instruction is received;
and the second distribution module is used for distributing the callback function in the task to be processed to the corresponding work thread for execution.
8. The apparatus of claim 7, further comprising:
and the triggering module is used for triggering the taking-out module to take out the next task to be processed of the current task to be processed from the asynchronous calling chain type storage structure when the completion of the current task to be processed is known.
9. The apparatus of claim 8, further comprising:
and the deleting module is used for deleting the asynchronous call chain type storage structure when the asynchronous call chain type storage structure is known to be empty.
10. The apparatus of claim 7, further comprising:
the suspension module is used for suspending the current task to be processed when a preset task suspension triggering instruction is received;
and the recovery module is used for recovering the execution of the suspended current task to be processed when a preset task recovery triggering instruction is received.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510439850.6A CN106371900B (en) | 2015-07-23 | 2015-07-23 | Data processing method and device for realizing asynchronous call |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510439850.6A CN106371900B (en) | 2015-07-23 | 2015-07-23 | Data processing method and device for realizing asynchronous call |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106371900A CN106371900A (en) | 2017-02-01 |
CN106371900B true CN106371900B (en) | 2020-06-05 |
Family
ID=57880702
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510439850.6A Active CN106371900B (en) | 2015-07-23 | 2015-07-23 | Data processing method and device for realizing asynchronous call |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106371900B (en) |
Families Citing this family (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107133112B (en) * | 2017-04-28 | 2019-12-03 | 维沃移动通信有限公司 | A kind of method and mobile terminal of asynchronous process fsync |
CN107239275A (en) * | 2017-05-17 | 2017-10-10 | 努比亚技术有限公司 | Using operation method, terminal and computer-readable recording medium |
CN108874557B (en) * | 2018-05-24 | 2022-03-22 | 广东睿江云计算股份有限公司 | Front-end interface processing method and system |
CN110659141B (en) * | 2018-06-30 | 2022-01-04 | 武汉斗鱼网络科技有限公司 | Instruction execution method and related equipment |
CN109918209B (en) * | 2019-01-28 | 2021-02-02 | 深兰科技(上海)有限公司 | Method and equipment for communication between threads |
CN112052078A (en) * | 2019-06-06 | 2020-12-08 | 阿里巴巴集团控股有限公司 | Time-consuming determination method and device |
CN111258782B (en) * | 2020-01-17 | 2023-11-03 | 京东科技信息技术有限公司 | Task queue processing method and device |
CN111858002B (en) * | 2020-07-16 | 2022-12-23 | 苏州浪潮智能科技有限公司 | Concurrent processing method, system and device based on asynchronous IO |
CN113918242A (en) * | 2020-11-23 | 2022-01-11 | 京东科技控股股份有限公司 | Application programming interface calling method and device, electronic equipment and storage medium |
CN112738417A (en) * | 2020-12-24 | 2021-04-30 | 浙江赫千电子科技有限公司 | Data acquisition, storage and display method for vehicle-mounted video |
CN113326039B (en) * | 2021-06-21 | 2022-02-18 | 深圳市网通兴技术发展有限公司 | Asynchronous code generation method and system for medical code flow modeling |
CN114205339A (en) * | 2021-12-01 | 2022-03-18 | 海南同享数字科技有限公司 | Asynchronous communication callback method, device, equipment and storage medium |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101770394A (en) * | 2008-12-29 | 2010-07-07 | 上海科泰世纪科技有限公司 | Asynchronous invoking method based on component interface |
CN101770395A (en) * | 2008-12-29 | 2010-07-07 | 上海科泰世纪科技有限公司 | Applet thread model and component invoking method based on same |
CN102567111A (en) * | 2011-12-23 | 2012-07-11 | 深圳市融创天下科技股份有限公司 | Method, system and terminal device capable of calling asynchronous procedure |
CN102841803A (en) * | 2011-06-24 | 2012-12-26 | 中兴通讯股份有限公司 | Method and device for asynchronously calling local codes in java thread |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7249355B2 (en) * | 2002-12-18 | 2007-07-24 | Microsoft Corporation | Unified network thread management |
US7363369B2 (en) * | 2003-10-16 | 2008-04-22 | International Business Machines Corporation | Monitoring thread usage to dynamically control a thread pool |
JP4414447B2 (en) * | 2007-04-25 | 2010-02-10 | 株式会社ソニー・コンピュータエンタテインメント | Information processing apparatus, information processing system, and information processing method |
CN102222037B (en) * | 2010-04-15 | 2014-04-02 | 国际商业机器公司 | Method and equipment for positioning bottleneck of JAVA program |
CN104063279B (en) * | 2013-03-20 | 2018-12-28 | 腾讯科技(深圳)有限公司 | Method for scheduling task, device and terminal |
-
2015
- 2015-07-23 CN CN201510439850.6A patent/CN106371900B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101770394A (en) * | 2008-12-29 | 2010-07-07 | 上海科泰世纪科技有限公司 | Asynchronous invoking method based on component interface |
CN101770395A (en) * | 2008-12-29 | 2010-07-07 | 上海科泰世纪科技有限公司 | Applet thread model and component invoking method based on same |
CN102841803A (en) * | 2011-06-24 | 2012-12-26 | 中兴通讯股份有限公司 | Method and device for asynchronously calling local codes in java thread |
CN102567111A (en) * | 2011-12-23 | 2012-07-11 | 深圳市融创天下科技股份有限公司 | Method, system and terminal device capable of calling asynchronous procedure |
Non-Patent Citations (3)
Title |
---|
Web服务组合执行引擎中服务异步调用机制研究;李玲勇 等;《计算机应用研究》;20100215;第27卷(第2期);第558-562页 * |
基于驱动程序的异步过程回调技术;屈景辉 等;《医疗卫生装备》;20031230(第10期);第251-252页 * |
物联网物流统一信息系统异步消息回调机制分析;林兴志;《The 2nd Asia-Pacific Conference on Information Network and Digital Content Security(2011APCID)》;20110701;第142-145页 * |
Also Published As
Publication number | Publication date |
---|---|
CN106371900A (en) | 2017-02-01 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106371900B (en) | Data processing method and device for realizing asynchronous call | |
US11237724B2 (en) | Mobile terminal and method for split screen control thereof, and computer readable storage medium | |
EP3531290A1 (en) | Data backup method, apparatus, electronic device, storage medium, and system | |
EP3404541B1 (en) | Application control method and related device | |
US20160315999A1 (en) | Device and method for associating applications | |
CN106502703B (en) | Function calling method and device | |
CN106708554B (en) | Program operating method and device | |
US10754684B2 (en) | Method for controlling process and related device | |
CN102830909A (en) | Icon management method for user interface and touch control equipment | |
CN106293901B (en) | Process management method and device for terminal application | |
CN107066268B (en) | Display position switching method and device for widget application | |
CN107908407B (en) | Compiling method and device and terminal equipment | |
CN104077184B (en) | A kind of course control method and computer system of application program | |
CN106371749A (en) | Method and device for terminal control | |
EP3418871B1 (en) | Swiping response acceleration method and related products | |
EP2869604B1 (en) | Method, apparatus and device for processing a mobile terminal resource | |
US11150913B2 (en) | Method, device, and terminal for accelerating startup of application | |
KR20110095586A (en) | Collecting method and apparatus of touch event for device | |
CN110677456A (en) | Resource allocation method and equipment | |
WO2017206851A1 (en) | Method for assigning installation task and mobile terminal | |
WO2015067206A1 (en) | File searching method and terminal | |
CN106776041B (en) | Data processing method and device | |
JP6685538B2 (en) | Application acceleration method and device | |
CN104461273A (en) | Information displaying method and terminal device | |
EP3344004B1 (en) | Communication method, mobile terminal and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | 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 |