CN113687879B - Interaction method and device for cross-platform framework and platform interaction library - Google Patents

Interaction method and device for cross-platform framework and platform interaction library Download PDF

Info

Publication number
CN113687879B
CN113687879B CN202110831592.1A CN202110831592A CN113687879B CN 113687879 B CN113687879 B CN 113687879B CN 202110831592 A CN202110831592 A CN 202110831592A CN 113687879 B CN113687879 B CN 113687879B
Authority
CN
China
Prior art keywords
program
thread
platform
target
cross
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
Application number
CN202110831592.1A
Other languages
Chinese (zh)
Other versions
CN113687879A (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.)
Chengdu Luyi Technology Co ltd
Original Assignee
Chengdu Luyi 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 Chengdu Luyi Technology Co ltd filed Critical Chengdu Luyi Technology Co ltd
Priority to CN202110831592.1A priority Critical patent/CN113687879B/en
Publication of CN113687879A publication Critical patent/CN113687879A/en
Application granted granted Critical
Publication of CN113687879B publication Critical patent/CN113687879B/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/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4488Object-oriented
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The application discloses an interaction method and device of a cross-platform framework and platform interaction library, a storage medium and computer equipment, wherein the method comprises the following steps: the cross-platform framework pre-loads a platform interaction library through a C++ program interface; the UI thread of the cross-platform framework calls the C++ program interface, and a function pointer of a target C++ program corresponding to the C++ program interface is transmitted to the platform interaction library; creating a new thread, executing the target C++ program through the new thread, and storing the context information of the UI thread; and after the execution of the target C++ program is finished, switching to the UI thread according to the context information of the UI thread, and calling back according to the function pointer of the target C++ program. The method and the device simplify the steps of the interaction between the platform code interaction library and the cross-platform framework UI, avoid the complicated operation that the bidirectional pipeline needs to be built in advance for the interaction through the bidirectional pipeline, and are simpler and more convenient.

Description

Interaction method and device for cross-platform framework and platform interaction library
Technical Field
The present invention relates to the field of computer technologies, and in particular, to an interaction method and apparatus for a cross-platform framework and platform interaction library, a storage medium, and a computer device.
Background
Cross-platform frameworks are a common technique in the field of computer development. In the prior art, callback between a cross-platform frame and a platform-related library is realized in a pipeline mode, the pipeline is half duplex, data can only be communicated in one way, two pipelines are required to be established when two-way communication is required, a result cannot be directly delivered to a UI thread when the result is returned through the pipeline, and because the platform-related code does not know how to deliver the message into a message cycle of the UI, the callback can only be firstly performed into the cross-platform frame (flutter), and at the moment, how to deliver the message into the message cycle of the UI is known, namely, the message is required to be delivered to the UI thread for a second time, so that the use is troublesome and the development amount is large.
Disclosure of Invention
In view of the above, the application provides an interaction method and device of a cross-platform framework and platform interaction library, a storage medium and computer equipment.
According to one aspect of the application, there is provided an interaction method of a cross-platform framework and a platform interaction library, including:
the cross-platform framework pre-loads a platform interaction library through a C++ program interface;
the UI thread of the cross-platform framework calls the C++ program interface, and a function pointer of a target C++ program corresponding to the C++ program interface is transmitted to the platform interaction library;
creating a new thread, executing the target C++ program through the new thread, and storing the context information of the UI thread;
and after the execution of the target C++ program is finished, switching to the UI thread according to the context information of the UI thread, and calling back according to the function pointer of the target C++ program.
Optionally, before the creating of the new thread, the method further includes:
judging whether the preset time-consuming time length corresponding to the target C++ program is greater than a preset time length threshold value or not;
and if the preset time consumption corresponding to the target C++ program is longer than the preset time duration threshold, executing the new thread creation.
Optionally, after the determining whether the preset time-consuming duration corresponding to the target c++ program is greater than the preset duration threshold, the method further includes:
if the preset time-consuming time length corresponding to the target C++ program is smaller than or equal to the preset time length threshold, executing the target C++ program through the UI thread, and storing the context information of the UI thread;
and after the execution of the target C++ program is finished, the UI thread is maintained, and callback is performed according to the context information of the UI thread and the function pointer of the target C++ program.
Optionally, the cross-platform framework comprises a flutter framework; the cross-platform framework pre-loads a platform interaction library through a C++ program interface, and specifically comprises the following steps:
referring to a ffi library, loading a C++ program interface through the ffi library, and loading the platform interaction library through the C++ program interface;
and the cross-platform framework calls the C++ program interface through the ffi library so as to realize the call of the platform interaction library through the C++ program interface.
Optionally, the target c++ program includes a filehelper.
The creating a new thread, executing the target C++ program through the new thread, and saving the context information of the UI thread, specifically comprising:
the platform interaction library stores the context information of the UI threads;
and the platform interaction library creates a new thread, the file helper so is executed through the new thread to read the file, and the execution result is stored in the platform interaction library.
Optionally, after the execution of the target c++ program is finished, switching to the UI thread according to the context information of the UI thread, and performing callback according to a function pointer of the target c++ program, including:
after the FileHelper.so execution is finished, switching to the UI thread according to the context information of the UI thread, and calling back according to the function pointer of the FileHelper.so, transmitting the execution result to the cross-platform framework, and analyzing and/or displaying the execution result in a preset mode.
According to another aspect of the present application, there is provided an interaction apparatus for a cross-platform framework and platform interaction library, including:
the preloading module is used for preloading a platform interaction library through a C++ program interface of the cross-platform framework;
the calling module is used for calling the C++ program interface by the UI thread of the cross-platform framework and transmitting a function pointer of a target C++ program corresponding to the C++ program interface to the platform interaction library;
the execution module is used for creating a new thread, executing the target C++ program through the new thread and storing the context information of the UI thread;
and the callback module is used for switching to the UI thread according to the context information of the UI thread after the execution of the target C++ program is finished, and executing callback according to the function pointer of the target C++ program.
Optionally, the apparatus further comprises:
the judging module is used for judging whether the preset time-consuming time length corresponding to the target C++ program is greater than a preset time length threshold before the new thread is created;
and the execution module is used for executing the new thread creation if the preset time consumption corresponding to the target C++ program is longer than the preset time length threshold.
Optionally, the apparatus further comprises:
the execution module is further configured to execute the target c++ program through the UI thread and store context information of the UI thread if the preset time-consuming duration corresponding to the target c++ program is less than or equal to the preset time duration threshold after the determining whether the preset time-consuming duration corresponding to the target c++ program is greater than the preset time duration threshold;
and the callback module is also used for keeping the UI thread after the execution of the target C++ program is finished, and carrying out callback according to the context information of the UI thread and the function pointer of the target C++ program.
Optionally, the cross-platform framework comprises a flutter framework; the preloading module is specifically configured to:
referring to a ffi library, loading a C++ program interface through the ffi library, and loading the platform interaction library through the C++ program interface;
and the cross-platform framework calls the C++ program interface through the ffi library so as to realize the call of the platform interaction library through the C++ program interface.
Optionally, the target c++ program includes a filehelper. The execution module is specifically configured to:
the platform interaction library stores the context information of the UI threads;
and the platform interaction library creates a new thread, the file helper so is executed through the new thread to read the file, and the execution result is stored in the platform interaction library.
Optionally, the callback module is specifically configured to:
after the FileHelper.so execution is finished, switching to the UI thread according to the context information of the UI thread, and calling back according to the function pointer of the FileHelper.so, transmitting the execution result to the cross-platform framework, and analyzing and/or displaying the execution result in a preset mode.
According to yet another aspect of the present application, there is provided a storage medium having stored thereon a computer program which, when executed by a processor, implements the above-described method of interaction of a cross-platform framework with a platform interaction library.
According to still another aspect of the present application, there is provided a computer device, including a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, where the processor implements the interaction method of the cross-platform framework and platform interaction library described above when the processor executes the program.
By means of the technical scheme, the interactive method and device for the cross-platform framework and the platform interaction library, the storage medium and the computer equipment are characterized in that the cross-platform framework pre-loads the platform interaction library through the C++ program interface, the C++ program interface is called through the UI thread of the cross-platform framework to call the platform interaction library through the cross-platform framework, the platform interaction library stores the context information of the UI thread, a new thread is asynchronously created, the target C++ program is executed through the new thread, and after the program execution is finished, the new thread is switched to the UI thread to carry out callback through the information after the writing-up is finished. According to the method and the device for the cross-platform framework UI, the steps of the interaction between the platform code interaction library and the cross-platform framework UI are simplified, the complex operation that the two-way pipeline is required to be built in advance for the interaction through the two-way pipeline is avoided, and the method and the device are simpler and more convenient.
The foregoing description is only an overview of the technical solutions of the present application, and may be implemented according to the content of the specification in order to make the technical means of the present application more clearly understood, and in order to make the above-mentioned and other objects, features and advantages of the present application more clearly understood, the following detailed description of the present application will be given.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiments of the application and together with the description serve to explain the application and do not constitute an undue limitation to the application. In the drawings:
fig. 1 is a schematic flow chart of an interaction method of a cross-platform framework and platform interaction library according to an embodiment of the present application;
FIG. 2 is a flowchart illustrating another method for interacting with a platform interaction library across a platform framework according to an embodiment of the present application;
FIG. 3 is a flowchart illustrating another method for interacting with a platform interaction library across a platform framework according to an embodiment of the present application;
FIG. 4 shows a schematic diagram of an interactive implementation provided by an embodiment of the present application;
fig. 5 shows a schematic structural diagram of another interaction device of a cross-platform framework and platform interaction library according to an embodiment of the present application.
Detailed Description
The present application will be described in detail hereinafter with reference to the accompanying drawings in conjunction with embodiments. It should be noted that, in the case of no conflict, the embodiments and features in the embodiments may be combined with each other.
In this embodiment, an interaction method of a cross-platform framework and a platform interaction library is provided, as shown in fig. 1, the method includes:
step 101, preloading a platform interaction library through a C++ program interface by a cross-platform framework;
step 102, the UI thread of the cross-platform framework calls the C++ program interface, and a function pointer of a target C++ program corresponding to the C++ program interface is transmitted to the platform interaction library;
step 103, creating a new thread, executing the target C++ program through the new thread, and storing the context information of the UI thread;
and 104, switching to the UI thread according to the context information of the UI thread after the execution of the target C++ program is finished, and performing callback according to a function pointer of the target C++ program.
In the embodiment of the application, the cross-platform framework can be specifically selected as a flutter framework, a platform code interaction library (platform interaction library) is preloaded by the flutter framework through a C++ program interface provided by a C++ program, the interaction connection between the flutter framework and the platform interaction library is established, and when the library provided by the cross-platform framework cannot meet the requirement of function development, the platform interaction library is loaded, and the function development is realized by means of the platform interaction library. When the UI threads of the cross-platform framework are subjected to function development after the platform interaction library is preloaded and connection between the platform interaction library and the UI threads is established, the C++ program interface can be called by the UI threads of the cross-platform framework to realize the call of the platform code interaction library, and a developer can simultaneously transmit callback function pointers of target C++ programs corresponding to the C++ program interface to the platform interaction library, wherein the target C++ programs can be C++ programs written through C++ languages to realize the development functions when the functions provided by the cross-platform framework can not meet development requirements and can meet the development functions only by means of interfaces such as an operating system, for example, the development functions can be file reading functions, and the target C++ programs can be file reading programs.
Further, the context information of the UI thread is saved through the platform interaction library so as to carry out callback later, under the condition that the logic ratio related to the platform is time consuming, the platform interaction library can carry out asynchronous call, a new thread is created, and the created new thread is utilized to execute the target C++ program. After the execution of the target C++ program is finished, for example, after a file is read, thread switching is performed, a new thread is switched to a UI thread to execute a callback, specifically, the new thread is switched to the UI thread according to the previously stored context information of the UI thread, and the UI thread is called to execute the callback according to a callback function pointer which is transmitted in advance.
By applying the technical scheme of the embodiment, the cross-platform framework pre-loads the platform interaction library through the C++ program interface, invokes the C++ program interface through the UI thread of the cross-platform framework so as to realize the cross-platform framework to invoke the platform interaction library, the platform interaction library stores the context information of the UI thread, asynchronously creates a new thread, executes the target C++ program through the new thread, and switches to the UI thread to carry out callback through the information after the program execution is finished. According to the method and the device for the cross-platform framework UI, the steps of the interaction between the platform code interaction library and the cross-platform framework UI are simplified, the complex operation that the two-way pipeline is required to be built in advance for the interaction through the two-way pipeline is avoided, and the method and the device are simpler and more convenient.
Further, as a refinement and extension of the foregoing embodiment, in order to fully describe a specific implementation procedure of the embodiment, another interaction method of a cross-platform framework and a platform interaction library is provided, as shown in fig. 2, where the method includes:
step 201, preloading a platform interaction library through a C++ program interface by a cross-platform framework;
step 202, the UI thread of the cross-platform framework calls the C++ program interface, and a function pointer of a target C++ program corresponding to the C++ program interface is transmitted to the platform interaction library;
step 203, judging whether the preset time-consuming time length corresponding to the target c++ program is greater than a preset time length threshold;
step 204, if the preset time consumption corresponding to the target c++ program is greater than the preset time period threshold, creating a new thread, executing the target c++ program by the new thread, and saving the context information of the UI thread; after the execution of the target C++ program is finished, switching to the UI thread according to the context information of the UI thread, and calling back according to a function pointer of the target C++ program;
step 205, if the preset time-consuming duration corresponding to the target c++ program is less than or equal to the preset time duration threshold, executing the target c++ program through the UI thread, and saving the context information of the UI thread; and after the execution of the target C++ program is finished, the UI thread is maintained, and callback is performed according to the context information of the UI thread and the function pointer of the target C++ program.
In the embodiment of the present application, before executing the target c++ program, it may be determined, according to a preset time-consuming period of the target c++ program written in advance, whether a new thread needs to be asynchronously created to execute the program. In a specific application scenario, the judgment can be performed according to the preset time-consuming time length of the target C++ program written in advance by a developer, or the average time-consuming time length of the program with the same function as the target C++ program is determined by counting the time-consuming time lengths of different functional programs according to historical big data, and the average time-consuming time length is used as the preset time-consuming time length corresponding to the target C++ program. If the preset time consumption corresponding to the target C++ program is longer than the preset time period threshold, creating a new thread to execute the program, otherwise, directly executing the program through the UI thread, and when the execution of the target C++ program is finished, maintaining the UI thread and executing callback according to a function pointer written in advance.
The platform interaction library in the embodiment of the application can be realized: 1. providing an asynchronous call, such as a logic related to a platform is time-consuming, wherein the platform interaction library can asynchronously call the method, and the asynchronous call can be in different threads or call threads (UI threads); 2. thread switching because there are some platform-dependent logic calls that are not being executed by the calling thread, and when they are completed, return to the calling thread to execute callbacks (which may cause UI throws exception if not completed); 3. a function call point is suspended to execute other logic, and execution is continued back to the suspension point (at this point execution may continue on the previous thread or on another thread).
FIG. 3 is a flow chart illustrating another method for interaction between a cross-platform framework and a platform interaction library according to an embodiment of the present application, where the method includes:
step 301, referring to a ffi library, loading a C++ program interface through the ffi library, and loading the platform interaction library through the C++ program interface;
step 302, the cross-platform framework calls the C++ program interface through a ffi library to realize the call of the platform interaction library through the C++ program interface;
step 303, the UI thread of the cross-platform framework calls the c++ program interface, and a function pointer of a target c++ program corresponding to the c++ program interface is transferred into the platform interaction library;
step 304, the platform interaction library stores the context information of the UI thread;
step 305, the platform interaction library creates a new thread, and the file helper so is executed through the new thread to read the file, and the execution result is saved in the platform interaction library;
and step 306, after the execution of the FileHelper. So is finished, switching to the UI thread according to the context information of the UI thread, and calling back according to the function pointer of the FileHelper. So, transmitting the execution result to the cross-platform framework, and analyzing and/or displaying the execution result in a preset mode.
In the above embodiment, in combination with a specific implementation manner provided in fig. 4, an ffi library may be introduced, a c++ program interface provided by a target c++ program is loaded through the ffi library, a platform interaction library is loaded through the c++ program interface, a cross-platform framework flutter invokes the c++ program interface through the ffi library, a UI thread of the cross-platform framework flutter invokes the c++ program interface, so that the cross-platform framework realizes the interaction with the platform interaction library through the c++ program interface, the platform interaction library stores the context information of the UI thread and creates a new thread, the new thread executes a file helper.
Further, as a specific implementation of the method of fig. 1, an embodiment of the present application provides an interaction device for a cross-platform framework and a platform interaction library, as shown in fig. 5, where the device includes:
the preloading module is used for preloading a platform interaction library through a C++ program interface of the cross-platform framework;
the calling module is used for calling the C++ program interface by the UI thread of the cross-platform framework and transmitting a function pointer of a target C++ program corresponding to the C++ program interface to the platform interaction library;
the execution module is used for creating a new thread, executing the target C++ program through the new thread and storing the context information of the UI thread;
and the callback module is used for switching to the UI thread according to the context information of the UI thread after the execution of the target C++ program is finished, and executing callback according to the function pointer of the target C++ program.
Optionally, the apparatus further comprises:
the judging module is used for judging whether the preset time-consuming time length corresponding to the target C++ program is greater than a preset time length threshold before the new thread is created;
and the execution module is used for executing the new thread creation if the preset time consumption corresponding to the target C++ program is longer than the preset time length threshold.
Optionally, the apparatus further comprises:
the execution module is further configured to execute the target c++ program through the UI thread and store context information of the UI thread if the preset time-consuming duration corresponding to the target c++ program is less than or equal to the preset time duration threshold after the determining whether the preset time-consuming duration corresponding to the target c++ program is greater than the preset time duration threshold;
and the callback module is also used for keeping the UI thread after the execution of the target C++ program is finished, and carrying out callback according to the context information of the UI thread and the function pointer of the target C++ program.
Optionally, the cross-platform framework comprises a flutter framework; the preloading module is specifically configured to:
referring to a ffi library, loading a C++ program interface through the ffi library, and loading the platform interaction library through the C++ program interface;
and the cross-platform framework calls the C++ program interface through the ffi library so as to realize the call of the platform interaction library through the C++ program interface.
Optionally, the target c++ program includes a filehelper. The execution module is specifically configured to:
the platform interaction library stores the context information of the UI threads;
and the platform interaction library creates a new thread, the file helper so is executed through the new thread to read the file, and the execution result is stored in the platform interaction library.
Optionally, the callback module is specifically configured to:
after the FileHelper.so execution is finished, switching to the UI thread according to the context information of the UI thread, and calling back according to the function pointer of the FileHelper.so, transmitting the execution result to the cross-platform framework, and analyzing and/or displaying the execution result in a preset mode.
It should be noted that, other corresponding descriptions of each functional unit related to the interaction device of the cross-platform framework and the platform interaction library provided in the embodiments of the present application may refer to corresponding descriptions in the methods of fig. 1 to fig. 4, which are not repeated herein.
Based on the above-mentioned methods shown in fig. 1 to 4, correspondingly, the embodiment of the application further provides a storage medium, on which a computer program is stored, where the computer program is executed by a processor to implement the above-mentioned interaction method of the cross-platform framework and the platform interaction library shown in fig. 1 to 4.
Based on such understanding, the technical solution of the present application may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (may be a CD-ROM, a U-disk, a mobile hard disk, etc.), and includes several instructions for causing a computer device (may be a personal computer, a server, or a network device, etc.) to perform the methods described in various implementation scenarios of the present application.
Based on the method shown in fig. 1 to fig. 4 and the virtual device embodiment shown in fig. 5, in order to achieve the above object, the embodiment of the present application further provides a computer device, which may specifically be a personal computer, a server, a network device, or the like, where the computer device includes a storage medium and a processor; a storage medium storing a computer program; and a processor for executing a computer program to implement the above-described interaction method of the cross-platform framework and platform interaction library as shown in fig. 1 to 4.
Optionally, the computer device may also include a user interface, a network interface, a camera, radio Frequency (RF) circuitry, sensors, audio circuitry, WI-FI modules, and the like. The user interface may include a Display screen (Display), an input unit such as a Keyboard (Keyboard), etc., and the optional user interface may also include a USB interface, a card reader interface, etc. The network interface may optionally include a standard wired interface, a wireless interface (e.g., bluetooth interface, WI-FI interface), etc.
It will be appreciated by those skilled in the art that the architecture of a computer device provided in the present embodiment is not limited to the computer device, and may include more or fewer components, or may combine certain components, or may be arranged in different components.
The storage medium may also include an operating system, a network communication module. An operating system is a program that manages and saves computer device hardware and software resources, supporting the execution of information handling programs and other software and/or programs. The network communication module is used for realizing communication among all components in the storage medium and communication with other hardware and software in the entity equipment.
Through the description of the above embodiments, it can be clearly understood by those skilled in the art that the application can be implemented by adding necessary general hardware platform by software, or by implementing cross-platform framework to pre-load platform interaction library by c++ program interface through hardware, and calling the platform interaction library by cross-platform framework UI thread to implement cross-platform framework call to the platform interaction library, the platform interaction library stores the context information of the UI thread, and asynchronously creates new thread, executes target c++ program by the new thread, and after the program execution is finished, switches to the UI thread to perform callback by writing up information. According to the method and the device for the cross-platform framework UI, the steps of the interaction between the platform code interaction library and the cross-platform framework UI are simplified, the complex operation that the two-way pipeline is required to be built in advance for the interaction through the two-way pipeline is avoided, and the method and the device are simpler and more convenient.
Those skilled in the art will appreciate that the drawings are merely schematic illustrations of one preferred implementation scenario, and that the modules or flows in the drawings are not necessarily required to practice the present application. Those skilled in the art will appreciate that modules in an apparatus in an implementation scenario may be distributed in an apparatus in an implementation scenario according to an implementation scenario description, or that corresponding changes may be located in one or more apparatuses different from the implementation scenario. The modules of the implementation scenario may be combined into one module, or may be further split into a plurality of sub-modules.
The foregoing application serial numbers are merely for description, and do not represent advantages or disadvantages of the implementation scenario. The foregoing disclosure is merely a few specific implementations of the present application, but the present application is not limited thereto and any variations that can be considered by a person skilled in the art shall fall within the protection scope of the present application.

Claims (10)

1. An interaction method of a cross-platform framework and a platform interaction library is characterized by comprising the following steps:
the cross-platform framework pre-loads a platform interaction library through a C++ program interface;
the UI thread of the cross-platform framework calls the C++ program interface, and a function pointer of a target C++ program corresponding to the C++ program interface is transmitted to the platform interaction library;
creating a new thread, executing the target C++ program through the new thread, and storing the context information of the UI thread;
and after the execution of the target C++ program is finished, switching to the UI thread according to the context information of the UI thread, and calling back according to the function pointer of the target C++ program.
2. The method of claim 1, wherein prior to creating the new thread, the method further comprises:
judging whether the preset time-consuming time length corresponding to the target C++ program is greater than a preset time length threshold value or not;
and if the preset time consumption corresponding to the target C++ program is longer than the preset time duration threshold, executing the new thread creation.
3. The method according to claim 2, wherein after the determining whether the preset time-consuming period corresponding to the target c++ program is greater than the preset time period threshold, the method further comprises:
if the preset time-consuming time length corresponding to the target C++ program is smaller than or equal to the preset time length threshold, executing the target C++ program through the UI thread, and storing the context information of the UI thread;
and after the execution of the target C++ program is finished, the UI thread is maintained, and callback is performed according to the context information of the UI thread and the function pointer of the target C++ program.
4. The method of claim 1, wherein the cross-platform framework comprises a flutter framework; the cross-platform framework pre-loads a platform interaction library through a C++ program interface, and specifically comprises the following steps:
referring to a ffi library, loading a C++ program interface through the ffi library, and loading the platform interaction library through the C++ program interface;
and the cross-platform framework calls the C++ program interface through the ffi library so as to realize the call of the platform interaction library through the C++ program interface.
5. The method of claim 4, wherein the target c++ program comprises a filehelper.so file reader program; the creating a new thread, executing the target C++ program through the new thread, and saving the context information of the UI thread, specifically comprising:
the platform interaction library stores the context information of the UI threads;
and the platform interaction library creates a new thread, the file helper so is executed through the new thread to read the file, and the execution result is stored in the platform interaction library.
6. The method according to claim 5, wherein after the execution of the target c++ program is finished, switching to the UI thread according to the context information of the UI thread, and performing callback according to a function pointer of the target c++ program, specifically comprising:
after the FileHelper.so execution is finished, switching to the UI thread according to the context information of the UI thread, and calling back according to the function pointer of the FileHelper.so, transmitting the execution result to the cross-platform framework, and analyzing and/or displaying the execution result in a preset mode.
7. An interaction device for a cross-platform framework and platform interaction library, comprising:
the preloading module is used for preloading a platform interaction library through a C++ program interface of the cross-platform framework;
the calling module is used for calling the C++ program interface by the UI thread of the cross-platform framework and transmitting a function pointer of a target C++ program corresponding to the C++ program interface to the platform interaction library;
the execution module is used for creating a new thread, executing the target C++ program through the new thread and storing the context information of the UI thread;
and the callback module is used for switching to the UI thread according to the context information of the UI thread after the execution of the target C++ program is finished, and executing callback according to the function pointer of the target C++ program.
8. The apparatus of claim 7, wherein the apparatus further comprises:
the judging module is used for judging whether the preset time-consuming time length corresponding to the target C++ program is greater than a preset time length threshold before the new thread is created;
and the execution module is used for executing the new thread creation if the preset time consumption corresponding to the target C++ program is longer than the preset time length threshold.
9. A storage medium having stored thereon a computer program, which when executed by a processor, implements the method of any of claims 1 to 6.
10. A computer device comprising a storage medium, a processor and a computer program stored on the storage medium and executable on the processor, characterized in that the processor implements the method of any one of claims 1 to 6 when executing the computer program.
CN202110831592.1A 2021-07-22 2021-07-22 Interaction method and device for cross-platform framework and platform interaction library Active CN113687879B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110831592.1A CN113687879B (en) 2021-07-22 2021-07-22 Interaction method and device for cross-platform framework and platform interaction library

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110831592.1A CN113687879B (en) 2021-07-22 2021-07-22 Interaction method and device for cross-platform framework and platform interaction library

Publications (2)

Publication Number Publication Date
CN113687879A CN113687879A (en) 2021-11-23
CN113687879B true CN113687879B (en) 2023-05-05

Family

ID=78577712

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110831592.1A Active CN113687879B (en) 2021-07-22 2021-07-22 Interaction method and device for cross-platform framework and platform interaction library

Country Status (1)

Country Link
CN (1) CN113687879B (en)

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106815002A (en) * 2015-12-01 2017-06-09 北京触控科技有限公司 A kind of implementation method of cross-platform development of games instrument
CN107133045A (en) * 2017-05-09 2017-09-05 上海雪鲤鱼计算机科技有限公司 Cross-platform game engine multi-threading correspondence method, device, storage medium and equipment
CN107562540A (en) * 2017-09-05 2018-01-09 武汉斗鱼网络科技有限公司 The method, apparatus and client of call back function are delivered to UI threads
CN108399120A (en) * 2017-02-06 2018-08-14 腾讯科技(深圳)有限公司 asynchronous message monitoring method and device
KR20190136258A (en) * 2018-05-30 2019-12-10 주식회사 티파이브온라인 Cross platform system and operation method for supporting multi thread
CN110691136A (en) * 2019-09-29 2020-01-14 广州华多网络科技有限公司 Data interaction method and device, electronic equipment and storage medium
CN110688601A (en) * 2019-09-18 2020-01-14 郑州阿帕斯科技有限公司 Data processing method and device
CN111176626A (en) * 2019-08-05 2020-05-19 腾讯科技(深圳)有限公司 Cross-programming-language code calling method and device, medium and equipment
CN112882690A (en) * 2021-01-28 2021-06-01 北京字节跳动网络技术有限公司 Application development method and device

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105354015A (en) * 2014-08-20 2016-02-24 南京普爱射线影像设备有限公司 Multi-thread communication technology
CN110018890B (en) * 2018-01-10 2021-07-30 武汉斗鱼网络科技有限公司 Interaction method between threads, electronic equipment and readable storage medium
CN108848154A (en) * 2018-06-08 2018-11-20 珠海市微半导体有限公司 A kind of method of mobile terminal Overpassing Platform by Using
US11343281B2 (en) * 2019-08-16 2022-05-24 Cisco Technology, Inc. Enhanced web application security communication protocol

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106815002A (en) * 2015-12-01 2017-06-09 北京触控科技有限公司 A kind of implementation method of cross-platform development of games instrument
CN108399120A (en) * 2017-02-06 2018-08-14 腾讯科技(深圳)有限公司 asynchronous message monitoring method and device
CN107133045A (en) * 2017-05-09 2017-09-05 上海雪鲤鱼计算机科技有限公司 Cross-platform game engine multi-threading correspondence method, device, storage medium and equipment
CN107562540A (en) * 2017-09-05 2018-01-09 武汉斗鱼网络科技有限公司 The method, apparatus and client of call back function are delivered to UI threads
KR20190136258A (en) * 2018-05-30 2019-12-10 주식회사 티파이브온라인 Cross platform system and operation method for supporting multi thread
CN111176626A (en) * 2019-08-05 2020-05-19 腾讯科技(深圳)有限公司 Cross-programming-language code calling method and device, medium and equipment
CN110688601A (en) * 2019-09-18 2020-01-14 郑州阿帕斯科技有限公司 Data processing method and device
CN110691136A (en) * 2019-09-29 2020-01-14 广州华多网络科技有限公司 Data interaction method and device, electronic equipment and storage medium
CN112882690A (en) * 2021-01-28 2021-06-01 北京字节跳动网络技术有限公司 Application development method and device

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
基于Qt的Android应用程序C/C++开发方法与实践;闫锋欣 等;《计算机***应用》;第27卷(第7期);96-102 *
谭东.《Android开发进阶实践拓展与提升》.机械工业出版社,2020,306-309. *
陈廷标 等.《网间网技术及其应用》.东南大学出版社,1998,137-140. *

Also Published As

Publication number Publication date
CN113687879A (en) 2021-11-23

Similar Documents

Publication Publication Date Title
WO2019174473A1 (en) User interface rendering method and apparatus, and terminal
US8601449B2 (en) Cross-platform application framework
EP2642394A1 (en) Test device
CN107251004A (en) The backward compatibility realized by using deception clock and fine-grained frequency control
CN111459586B (en) Remote assistance method, device, storage medium and terminal
CN111124668B (en) Memory release method, memory release device, storage medium and terminal
US20090083753A1 (en) Dynamic thread generation and management for improved computer program performance
CN107122176B (en) Graph drawing method and device
CN113377366A (en) Control editing method, device, equipment, readable storage medium and product
CN113990354A (en) Audio control method, device, equipment and storage medium based on Linux
CN116185743A (en) Dual graphics card contrast debugging method, device and medium of OpenGL interface
CN113365150B (en) Video processing method and video processing device
US20170017483A1 (en) Automatic import of third party analytics
CN111580883B (en) Application program starting method, device, computer system and medium
CN113419649A (en) Method for operating electronic device and device thereof
CN113687879B (en) Interaction method and device for cross-platform framework and platform interaction library
US20180052700A1 (en) Facilitation of guest application display from host operating system
CN113407259B (en) Scene loading method, device, equipment and storage medium
EP3848800B1 (en) Method and apparatus for displaying message box, terminal and storage medium
CN110442342B (en) Interface generation method and device, storage medium and computer equipment
CN110069417B (en) A/B test method and device
CN110716699A (en) Method and apparatus for writing data
Albazaz Design a mini-operating system for mobile phone.
CN117369820B (en) Rendering flow chart generation method, device and equipment
CN115033139B (en) Method and related device for starting application program interface

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