Inter-thread operation instruction synchronization system and method
By registering function objects in the game engine, the thread-to-thread operation instructions between the game scene editor and the game engine are synchronized, which solves the problems of synchronization delay and high coupling, ensures that the game scene editor can execute subsequent business logic in a timely manner, and reduces code complexity.
Patent Information
- Application Number
- CN202310332293.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-30
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2043-03-30
AI Technical Summary
In game development, there is a synchronization delay in the inter-thread operation instructions between the game scene editor and the game engine. This causes the game scene editor to be unable to obtain the synchronization results in time, thus preventing it from continuing to execute subsequent business logic. Furthermore, the threads are highly coupled.
By registering function objects in the second application through the first application, and calling these function objects in the second application to trigger the execution of the business functions of the first application, the operation instructions between threads are synchronized, reducing the number of interfaces and coupling between threads.
It achieves accurate synchronization of operation instructions between threads, avoids the game scene editor waiting during the synchronization process, reduces code complexity and improves development efficiency.
Smart Images

Figure CN116339829B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a system and method for synchronizing operation instructions between threads. Background Technology
[0002] In game development, the game scene editor is used to edit the virtual environment and virtual objects in the game, while the game engine is used to perform rendering based on the relevant data provided by the game scene editor.
[0003] The game scene editor and the game engine run on different threads. After the game scene editor starts, it invokes and runs the game engine. The game scene editor needs to frequently synchronize operation commands with the game engine, which involves synchronizing operation commands between different threads. In related technologies, developers expose synchronization interfaces between the game scene editor and the game engine threads. When the game scene editor needs to synchronize operation commands with the game engine, it calls the game engine's synchronization interface and transmits the required operation commands to the game engine through the synchronization interface. After receiving the synchronized operation commands, the game engine calls the game scene editor's synchronization interface to notify the game scene editor of the synchronization result. Once the game scene editor receives the synchronization result from the game engine, it continues to execute subsequent business logic.
[0004] When the game engine is under heavy load, if the game scene editor synchronizes operation commands with the game engine via its synchronization interface, the game engine may not be able to promptly call the scene editor's synchronization interface to provide feedback on the synchronization results. To ensure the game engine has accurately received the synchronized operation commands, the game scene editor needs to continuously wait for the game engine to provide feedback on the synchronization results, causing the game scene editor to be unable to continue executing subsequent business logic. Summary of the Invention
[0005] This application provides a system and method for synchronizing operation instructions between threads, which can avoid the problem that the first application will continuously wait during the synchronization of operation instructions, thus preventing the execution of subsequent business logic. The technical solution is as follows:
[0006] According to one aspect of this application, an inter-thread operation instruction synchronization system is provided, the system comprising: a first application and a second application, the first application being used to run on a first thread, and the second application being used to run on a second thread, wherein the first thread and the second thread are different;
[0007] The first application is used to invoke and run the second application during runtime;
[0008] The first application is further configured to register a function object of the first application in the second thread corresponding to the second application, wherein the function object of the first application is used to indicate the business function in the first application;
[0009] The second application is used to call the function object of the first application to trigger the execution of the business function indicated by the function object of the first application, wherein the business function encapsulates the operation instructions of the first application to synchronize with the second application.
[0010] According to another aspect of this application, a method for synchronizing operation instructions between threads is provided, the method being applied to a second application, the method comprising:
[0011] The application is launched and runs in the second thread according to the invocation instruction of the first application. The first application is used to run in the first thread, which is different from the second thread.
[0012] Receive the function object of the first application registered in the second thread by the first application, wherein the function object of the first application is used to indicate the business function in the first application;
[0013] The function object of the first application is invoked to trigger the execution of the business function indicated by the function object of the first application, the business function encapsulating the operation instructions of the first application to synchronize with the second application.
[0014] According to another aspect of this application, a method for synchronizing operation instructions between threads is provided, the method being applied to a first application, the method comprising:
[0015] During the execution of the first application, a second application is invoked and run, while the first application is used to run in the first thread;
[0016] In the second thread corresponding to the second application, a function object of the first application is registered. The second application is used to run in the second thread. The first thread is different from the second thread. The function object is used to indicate the business function in the first application.
[0017] In the case where the second application calls the function object of the first application, the function object is used to trigger the execution of the business function, which encapsulates the operation instructions for the first application to synchronize with the second application.
[0018] According to another aspect of this application, an inter-thread operation instruction synchronization device is provided, the device comprising:
[0019] The running module is used to start running in the second thread according to the invocation instruction of the first application, the first application is used to run in the first thread, and the first thread is different from the second thread;
[0020] A receiving module is configured to receive a function object of the first application registered by the first application in the second thread, wherein the function object of the first application is used to indicate the business function in the first application;
[0021] The calling module is used to call the function object of the first application to trigger the execution of the business function indicated by the function object of the first application, wherein the business function encapsulates the operation instructions for the first application to synchronize with the second application.
[0022] In an optional design, the function object of the first application encapsulates the memory address of the business function; the calling module is used to:
[0023] The function object of the first application is invoked to obtain the business function through the memory address and trigger the execution of the business function.
[0024] In an optional design, the function object of the first application encapsulates a callback function, and the callback function corresponds to at least one pointer; the calling module is used to:
[0025] Invoke the function object of the first application to run the callback function;
[0026] Based on the at least one pointer corresponding to the callback function, the business function indicated by the at least one pointer in the first application is triggered and executed;
[0027] Each of the at least one pointer points to the memory address of a business function in the first application.
[0028] In an optional design, the receiving module is used for:
[0029] Create a function storage area in the second thread;
[0030] Receive a function object from the first application, the function object being registered by the first application in the function storage area of the second thread.
[0031] In an optional design, the device provides a registration interface; the receiving module is used for:
[0032] The first application's function object is received through the registration interface. The function object is registered by the first application in the function storage area of the second thread through the registration interface.
[0033] In an optional design, the business function is used to synchronize data; the calling module is used to:
[0034] The function object of the first application is invoked to trigger the execution of the business function indicated by the function object of the first application, and the execution result data of the business function is obtained.
[0035] According to another aspect of this application, an inter-thread operation instruction synchronization device is provided, the device comprising:
[0036] A trigger module is used to trigger and run a second application during the operation of the device, the device being used to run a first thread;
[0037] A registration module is used to register function objects of the device in a second thread corresponding to the second application. The second application is used to run in the second thread, which is different from the first thread. The function objects are used to indicate business functions in the device.
[0038] In the case where the second application calls the function object of the device, the function object is used to trigger the execution of the business function, which encapsulates the operation instructions from the first application to the second application.
[0039] In an optional design, the registration module is used for:
[0040] In the function storage area of the second thread corresponding to the second application, the function object of the device is registered, and the function storage area is created by the second application.
[0041] In an optional design, the second application provides a registration interface; the registration module is used for:
[0042] By calling the registration interface, the function object of the device is registered in the function storage area of the second thread corresponding to the second application.
[0043] According to another aspect of this application, a computer device is provided, the computer device including a processor and a memory, the memory storing at least one instruction, at least one program, code set or instruction set, the at least one instruction, the at least one program, the code set or instruction set being loaded and executed by the processor to implement the inter-thread operation instruction synchronization method as described above.
[0044] According to another aspect of this application, a computer-readable storage medium is provided, wherein at least one instruction, at least one program, code set, or instruction set is stored therein, wherein the at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by a processor to implement the inter-thread operation instruction synchronization method as described above.
[0045] According to another aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the inter-thread operation instruction synchronization method provided in various alternative implementations of the above aspects.
[0046] The beneficial effects of the technical solution provided in this application include at least the following:
[0047] By registering a function object in the second application and calling this function object, the second application can trigger the execution of a business function in the first application. Since this business function encapsulates the synchronization instructions from the first application to the second application, thread-to-thread operation instruction synchronization is achieved. Because the second application obtains the necessary synchronization instructions by executing the business function in the first application, accurate acquisition of these instructions is guaranteed. Therefore, the first application can execute subsequent business logic immediately after registering the function object, without additional waiting. In the case of a game scene editor as the first application, this avoids the problem of the game scene editor continuously waiting during the synchronization of operation instructions, which could prevent the execution of subsequent business logic. Attached Figure Description
[0048] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0049] Figure 1 This is a schematic diagram illustrating the process of synchronizing operation instructions between a first application and a second application, provided in an exemplary embodiment of this application.
[0050] Figure 2 This is a structural block diagram of an inter-thread operation instruction synchronization system provided in an exemplary embodiment of this application;
[0051] Figure 3 This is a flowchart illustrating an exemplary embodiment of the method for synchronizing operation instructions between threads provided in this application;
[0052] Figure 4 This is a flowchart illustrating an exemplary embodiment of the method for synchronizing operation instructions between threads provided in this application;
[0053] Figure 5 This is a flowchart illustrating an exemplary embodiment of the method for synchronizing operation instructions between threads provided in this application;
[0054] Figure 6 This is a flowchart illustrating the operation of a game scene editor and a game engine provided in an exemplary embodiment of this application;
[0055] Figure 7 This is a schematic diagram of the structure of an inter-thread operation instruction synchronization device provided in an exemplary embodiment of this application;
[0056] Figure 8 This is a schematic diagram of the structure of an inter-thread operation instruction synchronization device provided in an exemplary embodiment of this application;
[0057] Figure 9 This is a schematic diagram of the structure of an inter-thread operation instruction synchronization device provided in an exemplary embodiment of this application;
[0058] Figure 10 This is a schematic diagram of the structure of a computer device provided in an exemplary embodiment of this application.
[0059] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application. Detailed Implementation
[0060] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0061] First, let me introduce the terms used in this application:
[0062] Thread: refers to the smallest unit of computation that can be scheduled in an operating system. Each application contains at least one thread to support the normal operation of the application.
[0063] Function objects: These are used to encapsulate specific business logic. A function object can provide at least one method, and the caller can indirectly execute the business logic encapsulated within the function object by invoking the method provided by the function object.
[0064] Editor: An editor is a software program, generally referring to writing software used to modify computer files. Common editors include text editors, web page editors, source code editors, image editors, sound editors, and video editors. In this application, the editor refers to a game scene editor, which is used to edit in-game scenes (levels), such as editing virtual environments and virtual objects within the game.
[0065] Game Engine: A game engine can be viewed as a collection of machine-readable code (instructions) designed for the operation of a game. It acts like an engine, controlling the game's execution. A game can be divided into two main parts: the game engine and game resources. Game resources include images, sounds, animations, and other content. The game engine calls these resources sequentially according to the game's design requirements to control the game's operation and render its visuals.
[0066] Virtual environment: This refers to the virtual environment displayed (or provided) when an application (game) runs on a terminal. This virtual environment can be a simulation of the real world, a semi-simulated / semi-fictional environment, or a purely fictional environment. The virtual environment can be any of a two-dimensional, 2.5-dimensional, or three-dimensional virtual environment; this application does not limit this.
[0067] Virtual object: refers to at least one movable or fixed object in a virtual environment, controlled by the user or not. This virtual object can be a simulation of a real-world object, a semi-simulated / semi-fictional object, or a completely fictional object. Each virtual object has its own shape and volume in the virtual environment and occupies a portion of the space within the virtual environment.
[0068] In game development, the game scene editor is used to edit the virtual environment and virtual objects in the game, while the game engine performs rendering based on the data provided by the game scene editor. The game scene editor and the game engine run on different threads; for example, the game scene editor runs on a thread created by C# (a programming language), while the game engine runs on a thread created by C++ (a programming language).
[0069] Once the game scene editor starts, it will invoke and run the game engine. The game engine needs to obtain relevant data from the game scene editor to render the game graphics. Therefore, the game scene editor needs to frequently synchronize operation commands with the game engine, which involves synchronizing operation commands between the different threads of the game scene editor and the game engine.
[0070] In related technologies, developers expose synchronization interfaces to each other in the threads of the game scene editor and the game engine. During the operation of the game scene editor and the game engine, the game scene editor and the game engine call the exposed synchronization interfaces in sequence. This allows the game scene editor to transmit operation commands that need to be synchronized to the game engine through the synchronization interface, and the game engine to feed back the operation command synchronization results to the game scene editor through the synchronization interface, thereby realizing the synchronization of operation commands between the game scene editor and the game engine.
[0071] When the game engine is under heavy load, if the game scene editor synchronizes operation commands with the game engine via its synchronization interface, the game engine may not be able to promptly call the scene editor's synchronization interface to provide feedback on the synchronization results. To ensure the game engine accurately obtains and executes the synchronized operation commands, the game scene editor needs to continuously wait for the game engine to provide feedback on the synchronization results, preventing the scene editor from executing subsequent business logic. Furthermore, implementing this solution for synchronizing operation commands between different threads requires developing interfaces in both the game scene editor and game engine threads, and these interfaces need to be called between the two threads, resulting in high coupling between threads.
[0072] The method provided in this application involves a first application registering a function object in a second application. The second application can trigger the execution of a business function in the first application by calling the function object. Since this business function encapsulates the operation instructions for synchronization between the first and second applications, it achieves synchronization of operation instructions between threads. Because the second application obtains the operation instructions to be synchronized by executing the business function in the first application, it can ensure accurate acquisition of the required operation instructions. Therefore, the first application can execute subsequent business logic immediately after registering the function object without additional waiting. In the case of a game scene editor, this avoids the problem of the game scene editor continuously waiting during the synchronization of operation instructions, which would prevent the execution of subsequent business logic. In addition, when implementing the synchronization of operation instructions between different threads, only the function object needs to be registered in a single thread, without developing a synchronization interface for each thread, and without calls between the two threads. This effectively reduces the number of interfaces that need to be provided between the two threads and solves the problem of high coupling between threads caused by calls between threads for synchronizing operation instructions. It also reduces code complexity and improves code maintainability and development efficiency.
[0073] For example, the method provided in this application embodiment can be used in the development of games such as first-person shooter (FPS) games, third-person shooter (TPS) games, massively multiplayer online role-playing games (MMORPGs), multiplayer online battle arena (MOBA) games, simulation games (SLGs), and sandbox games.
[0074] Figure 1 This is a schematic diagram illustrating the process of synchronizing operation instructions between a first application and a second application, provided in an exemplary embodiment of this application. Figure 1 As shown, a first application 101 runs on a first thread, and a second application 102 runs on a second thread, which is different from the first thread. For example, the first application 101 is a game scene editor, and the second application 102 is a game engine. During the execution of the first application 101, the second application 102 will be invoked and run.
[0075] After the second application 102 is launched, it creates a function storage area 103 in its second thread. The first application 101 registers its function object 104 in the function storage area 103 of the second thread of the second application 102. Optionally, the second application 102 provides a registration interface, which the first application 101 calls to register its function object 104 in the function storage area 103 of the second thread of the second application 102. After the first application 101 registers the function object 104, the second application 102 can call the function object 104 in the function storage area 103. The function object 104 is used to indicate the business function 105 in the first application 101. By calling the function object 104, the second application 102 can trigger the execution of the business function 105. The business function 105 encapsulates the operation instructions synchronized by the first application 101 to the second application 102. Therefore, the second application 102 can obtain and execute the operation instructions synchronized by the first application 101 to it. Optionally, the business function 105 can also be used to synchronize data. By triggering the execution of the business function 105, the second application 102 can synchronize data with the first application 101. Optionally, the function object 104 is used to instruct the business function 105 in the first application 101 for handling user operations. Through the function object 104, the first application 101 can synchronize user operation-related data to the second application 102.
[0076] By registering a function object in the second application and calling it in the first application, the second application can trigger the execution of business functions in the first application. Since these business functions encapsulate the synchronization instructions from the first application to the second application, thread-to-thread synchronization of operation instructions is achieved. Because the second application obtains the necessary synchronization instructions by executing the business functions in the first application, accurate acquisition of these instructions is guaranteed. Therefore, the first application can execute subsequent business logic immediately after registering the function object, without additional waiting. In the case of a game scene editor, this avoids the problem of the game scene editor continuously waiting during the synchronization of operation instructions, preventing the execution of subsequent business logic. Furthermore, when implementing operation instruction synchronization between different threads, only the function object needs to be registered in a single thread; there is no need to develop synchronization interfaces for each thread, and no calls between the two threads are required. This effectively reduces the number of interfaces that need to be provided between the two threads and solves the problem of high thread coupling caused by inter-thread calls for synchronization of operation instructions.
[0077] Figure 2This is a structural block diagram of an inter-thread operation instruction synchronization system provided in an exemplary embodiment of this application. The inter-thread operation instruction synchronization system 200 includes: a first application 201 and a second application 202, wherein the first application 201 is used to run on a first thread, and the second application 202 is used to run on a second thread, and the first thread and the second thread are different.
[0078] The first application 201 is used to invoke and run the second application 202 during operation;
[0079] The first application 201 is also used to register a function object of the first application 201 in the second thread corresponding to the second application 202. The function object of the first application 201 is used to indicate the business function in the first application 201.
[0080] The second application 202 is used to call the function object of the first application 201 to trigger the execution of the business function indicated by the function object of the first application 201. The business function encapsulates the operation instructions of the first application 201 to synchronize with the second application 202.
[0081] In some embodiments, the function object of the first application 201 encapsulates the memory address of the business function;
[0082] The second application 202 is used to call the function object of the first application 201 to obtain the business function through the memory address and trigger the execution of the business function.
[0083] In some embodiments, the function object of the first application 201 encapsulates a callback function, and the callback function corresponds to at least one pointer; the second application 202 is used for:
[0084] Invoke the function object of the first application 201 to run the callback function;
[0085] Based on at least one pointer corresponding to the callback function, trigger the execution of at least one business function indicated by the pointer in the first application 201;
[0086] Each of at least one of the pointers points to the memory address of a business function in the first application 201.
[0087] In some embodiments, the second application 202 is also used to create a function storage area in a second thread;
[0088] The first application 201 is used to register the function object of the first application 201 in the function storage area of the second thread.
[0089] In some embodiments, the second application 202 provides a registration interface;
[0090] The first application 201 is used to register the function object of the first application 201 in the function storage area of the second thread by calling the registration interface.
[0091] In some embodiments, the second application 202 is used to create a function storage area in a second thread when it is invoked and run by the first application 201;
[0092] The second application 202 is also used to clear the function storage area of the second thread when the runtime ends.
[0093] In some embodiments, the business function is used to synchronize data;
[0094] The second application 202 is also used to call the function object of the first application 201 to trigger the execution of the business function indicated by the function object of the first application 201, and obtain the execution result data of the business function.
[0095] In some embodiments, the business function is used to process user operations in the first application 201;
[0096] The first application 201 is used to register the function object of the first application 201 in the second thread corresponding to the second application 202 in response to receiving a user operation;
[0097] The first application 201 is also used to respond to the business function's triggering of execution, pass user operations to the business function, so that the business function runs based on the user operations and outputs the execution result data.
[0098] In some embodiments, the first thread is a thread created based on a first development language, and the second thread is a thread created based on a second development language, wherein the first development language and the second development language are different.
[0099] In some embodiments, the second application 202 is also used to call the function object of the first application 201 when a triggering condition is met during operation.
[0100] In some embodiments, the first application 201 is a game scene editor, and the second application 202 is a game engine, which is used to perform rendering based on the data provided by the game scene editor.
[0101] In summary, the system provided in this embodiment registers a function object in a second application through a first application. The second application can trigger the execution of a business function in the first application by calling this function object. Since this business function encapsulates the operation instructions for synchronization between the first and second applications, it achieves synchronization of operation instructions between threads. Because the second application obtains the operation instructions that need to be synchronized by executing the business function in the first application, it can ensure that the required operation instructions are accurately obtained. Therefore, the first application can execute subsequent business logic immediately after registering the function object without additional waiting. When the first application is a game scene editor, it avoids the problem of the game scene editor continuously waiting during the synchronization of operation instructions, which would prevent the execution of subsequent business logic.
[0102] Figure 3 This is a flowchart illustrating a method for synchronizing inter-thread operation instructions according to an exemplary embodiment of this application. This method can be used in a first application. For example... Figure 3 As shown, the method includes:
[0103] Step 302: During the execution of the first application, launch and run the second application.
[0104] A first application runs on a first thread, and a second application runs on a second thread. The first thread and the second thread are different. Optionally, the development language of the first thread is different from that of the second thread. For example, the first thread is created in C#, and the second thread is created in C++. Optionally, the first application is a game scene editor, and the second application is a game engine.
[0105] After the first application starts, it runs its own business logic. When the first application runs its own business logic to invoke the second application, it will invoke the second application. The business logic within the first application and the order in which it runs are configured by the developers.
[0106] Step 304: In the second thread corresponding to the second application, register the function object of the first application.
[0107] After being launched by the first application, the second application runs in its corresponding second thread. After the first application registers a function object in the second thread corresponding to the second application, the second application can call the registered function object in the second thread to execute the business logic encapsulated in the function object.
[0108] Optionally, the second application can create a function storage area in its corresponding second thread to store function objects. Function objects registered by the first application in the second thread will be stored in the function storage area of the second thread by the second application.
[0109] After the second application starts, it runs its own business logic. While the second application is running its business logic to create the function storage area, it creates the function storage area in a second thread. The business logic in the second application and the order in which it runs are set by the developers.
[0110] The function object of the first application indicates a business function within the first application. This business function encapsulates operation instructions that the first application synchronizes with the second application. These operation instructions are used by the first application to control the operation of the second application. Optionally, the business function encapsulates one or more operation instructions. By calling this function object, the second application can obtain and execute one or more operation instructions synchronized with it by the first application. Optionally, these operation instructions are set by the developer or generated by the first application, for example, based on user actions within the first application. When the second application executes these operation instructions, it produces corresponding results.
[0111] Optionally, the function object of the first application encapsulates business logic for synchronizing data with the second application. The second application executes this business logic by calling the function object, thus synchronizing data with the first application, achieving data synchronization between the two applications—that is, data synchronization between the first thread and the second thread. Specifically, the function object of the first application indicates the business function within it, and the result of this business function is the data that the first application needs to synchronize with the second application. When the second application calls the function object of the first application, this function object triggers the execution of the business function in the first application, allowing the second application to obtain the result data of the first application's business function—that is, to obtain the data that the first application needs to synchronize with the second application—thus achieving data synchronization between the two applications.
[0112] Optionally, the function object is used to indicate the business function in the first application for processing user operations, and the first application can synchronize user operation-related data to the second application through the function object.
[0113] When the second application runs business logic that calls function objects in the function store, the second application calls the function object, thereby synchronizing data with the first application.
[0114] After the first application registers its function object in the second thread, the first application will continue to execute its subsequent business logic.
[0115] In summary, the method provided in this embodiment involves a first application registering a function object in a second application. The second application can trigger the execution of a business function in the first application by calling this function object. Since this business function encapsulates the operation instructions from the first application to the second application for synchronization, inter-thread operation instruction synchronization is achieved. Because the second application obtains the required synchronization instructions by executing the business function in the first application, accurate acquisition of the required synchronization instructions is guaranteed. Therefore, the first application can execute subsequent business logic immediately after registering the function object without additional waiting. In the case where the first application is a game scene editor, this avoids the problem of the game scene editor continuously waiting during the synchronization of operation instructions, which could prevent the execution of subsequent business logic.
[0116] Figure 4 This is a flowchart illustrating a method for synchronizing inter-thread operation instructions according to an exemplary embodiment of this application. This method can be used in a second application. For example... Figure 4 As shown, the method includes:
[0117] Step 402: Start running in the second thread according to the invocation instruction of the first application.
[0118] A first application runs on a first thread, and a second application runs on a second thread; the first thread and the second thread are different. Optionally, the development language corresponding to the first thread is different from the development language corresponding to the second thread. Optionally, the first application is a game scene editor, and the second application is a game engine.
[0119] Step 404: Receive the function object of the first application registered in the second thread by the first application.
[0120] After being launched by the first application, the second application runs in its corresponding second thread. After the first application registers a function object in the second thread corresponding to the second application, the second application can call the registered function object in the second thread to execute the business logic encapsulated in the function object.
[0121] Optionally, the second application can create a function storage area in its corresponding second thread to store function objects. Function objects registered by the first application in the second thread will be stored in the function storage area of the second thread by the second application.
[0122] Step 406: Invoke the function object of the first application to trigger the business function indicated by the function object of the first application.
[0123] The function object of the first application refers to the business function within the first application. This business function encapsulates the operation instructions that the first application synchronizes with the second application. These operation instructions are used by the first application to control the operation of the second application. By calling this function object, the second application can obtain and execute the operation instructions synchronized with it by the first application. Optionally, these operation instructions are set by the developers or generated by the first application, for example, based on user actions within the first application. Running these operation instructions in the second application will produce corresponding results.
[0124] Optionally, the function object of the first application encapsulates business logic for synchronizing data with the second application. The second application executes this business logic by calling the function object, thus synchronizing data with the first application, achieving data synchronization between the two applications, i.e., data synchronization between the first thread and the second thread. Specifically, the function object of the first application indicates the business function within the first application. Optionally, the function object of the first application encapsulates the memory address of the business function. When the second application calls this business function, it triggers the execution of the function indicated by that memory address, i.e., the business function in the first application. The execution result data of this business function obtained by the second application is the data that the first application needs to synchronize with the second application.
[0125] Optionally, the function object is used to indicate the business function in the first application for processing user operations, and the first application can synchronize user operation-related data to the second application through the function object.
[0126] In summary, the method provided in this embodiment involves a first application registering a function object in a second application. The second application can trigger the execution of a business function in the first application by calling this function object. Since this business function encapsulates the operation instructions from the first application to the second application for synchronization, inter-thread operation instruction synchronization is achieved. Because the second application obtains the required synchronization instructions by executing the business function in the first application, accurate acquisition of the required synchronization instructions is guaranteed. Therefore, the first application can execute subsequent business logic immediately after registering the function object without additional waiting. In the case where the first application is a game scene editor, this avoids the problem of the game scene editor continuously waiting during the synchronization of operation instructions, which could prevent the execution of subsequent business logic.
[0127] Figure 5 This is a flowchart illustrating an exemplary embodiment of the method for synchronizing operation instructions between threads provided in this application. Figure 5 As shown, the method includes:
[0128] Step 502: During the operation of the first application, the first application invokes and runs the second application.
[0129] A first application runs on a first thread, and a second application runs on a second thread; the first thread and the second thread are different. Optionally, the first thread is created using a first programming language, and the second thread is created using a second programming language; the first and second programming languages are different. For example, the first thread is created in C#, and the second thread is created in C++.
[0130] For example, the first application is a game scene editor, and the second application is a game engine, which is used to perform rendering based on the data provided by the game scene editor.
[0131] After the first application starts, it runs its own business logic. When the first application runs its own business logic to invoke the second application, it will invoke the second application. The business logic within the first application and the order in which it runs are configured by the developers.
[0132] Step 504: The second application creates a function storage area in the second thread corresponding to the second application.
[0133] After being launched by the first application, the second application runs in its corresponding second thread and creates a function storage area within that thread. This function storage area stores function objects that encapsulate business logic. During its execution, the second application can call the function objects stored in the function storage area. When the second application calls a function object in the function storage area, it executes the business logic encapsulated within the function object, such as performing data synchronization logic with other applications.
[0134] Optionally, when the second application is launched and run by the first application, the second application creates a function storage area in the second thread. Optionally, when the second application terminates, the second application also clears the function storage area of the second thread, that is, it clears the function storage area created by the second application and the function objects stored in the function storage area.
[0135] After the second application starts, it runs its own business logic. While the second application is running its business logic to create the function storage area, it creates the function storage area in a second thread. The business logic in the second application and the order in which it runs are set by the developers.
[0136] Step 506: The first application registers its function object in the function storage area of the second thread.
[0137] The function object of the first application is used to indicate the business functions within the first application. This function object allows the execution of these business functions to be triggered. The business function encapsulates the operation instructions for synchronizing data between the first and second applications. Optionally, when the first application receives relevant information for processing business functions during its execution, and needs to synchronize data with the second application, the first application will register its function object in the second thread to achieve data synchronization with the second application.
[0138] Optionally, this business function handles user operations in the first application. In response to the first application receiving a user operation, the first application registers a function object in the second thread corresponding to the second application to instruct the business function to synchronize user operation-related data with the second application. For example, when the first application receives human-computer interaction information from the user interface of the first application, it triggers the first application to register a function object corresponding to the business function used to handle the human-computer interaction information in the second thread. For instance, when the first application detects a user dragging operation on a virtual object displayed in the user interface, it registers a business function in the first application in the second thread to handle the dragging operation information, thereby synchronizing the data of the related instructions generated by the dragging operation information with the second application. Optionally, the business function that needs to register a function object in the first application and the logic that triggers the registration of the function object in the first application are set by the developers.
[0139] After the first application registers a function object in the function storage area of the second thread, the second application can call the registered function object in the function storage area to execute the business logic encapsulated in the function object. For example, if the function object encapsulates business logic for data synchronization with the first application, the second application can achieve data synchronization with the first application by calling the function object.
[0140] Optionally, the second application provides a registration interface exposed to the outside world. This registration interface is used to register function objects in the function storage area. By calling the registration interface, the first application can transmit the function objects that the first application needs to register to the second application. The second application can receive the function objects transmitted by the first application through the registration interface, thereby enabling the first application to register its function objects in the function storage area of the second thread through the registration interface.
[0141] For example, the code for defining a class that provides a function object registration interface and creates a function storage area for the second application is as follows:
[0142]
[0143]
[0144] The code above defines an OperationManager class. Through this class, the second application can expose an interface for registering function objects for operations. The second application can also use this class to implement methods for creating the storage area (configoperationContainer) corresponding to the function object of the operation.
[0145] After the first application registers its function object in the second thread, the first application will continue to execute its subsequent business logic.
[0146] Step 508: The second application calls the function object of the first application to trigger the execution of the business function indicated by the function object.
[0147] The function object of the first application indicates a business function within the first application. This business function encapsulates operation instructions that the first application synchronizes with the second application. These operation instructions are used by the first application to control the operation of the second application. Optionally, the business function encapsulates one or more operation instructions. By calling this function object, the second application can obtain and execute one or more operation instructions synchronized with it by the first application. Optionally, these operation instructions are set by the developer or generated by the first application, for example, based on user actions within the first application. When the second application executes these operation instructions, it produces corresponding results.
[0148] For example, if the game engine is currently displaying the user interface of the game activity, and when the game engine needs to close this user interface, the first application can generate an operation instruction to close the user interface, encapsulate it in a business function, and register it with the second application through a function object. The second application, by calling this function object, triggers the business function of the first application to obtain and execute the operation instruction, thereby closing the user interface of the game activity.
[0149] Optionally, the business function is a function in the first application, that is, a function that needs to transmit data to the second application. The function object of the first application is used to indicate the business function of the first application. By calling the function object, the second application can trigger the execution of the business function, and by obtaining the execution result data of the business function, data synchronization between the first application and the second application can be achieved, that is, data synchronization between the first thread and the second thread.
[0150] Optionally, the function object of the first application encapsulates the memory address of the business function of the first application. When the second application calls the function object of the first application, it can obtain the memory address of the business function, thereby accessing the business function through the memory address and triggering its execution.
[0151] Optionally, the function object of the first application encapsulates a callback function, which corresponds to at least one pointer. When the second application calls the function object of the first application, it executes the callback function encapsulated in the function object. Each pointer corresponding to this callback function points to the memory address of a business function in the first application. Since functions share memory addresses, when the second application executes the callback function, it can call back to the corresponding business function in the first application through the memory address pointed to by the pointer. After calling the business function of the first application, the execution of the business function in the first application is triggered, allowing the second application to obtain the execution result data of the business function, thereby achieving data synchronization with the first application. Optionally, when the second application runs the callback function, it triggers the execution of the business functions pointed to by all the pointers corresponding to the callback function, thereby obtaining the execution result data of the business functions pointed to by all the pointers; or, when the second application runs the callback function, it triggers the execution of the business functions pointed to by some of the pointers corresponding to the callback function, thereby obtaining the execution result data of the business functions pointed to by some of the pointers. That is, the second application can obtain the execution result data of one or more business functions in the first application by calling the function object once.
[0152] Optionally, the business functions triggered by the second application can be considered as running within the second application, with computing resources provided by the second application. The number of business functions triggered by the second application via pointers is set by the developers or determined by the second application based on conditions. For example, the second application might determine the number of business functions to trigger based on the current remaining computing resources, and this number is proportional to the remaining computing resources.
[0153] Optionally, the function object of the first application is used to indicate the business function in the first application used to handle user operations. Through this function object, the first application can synchronize user operation-related data with the second application. After the first application receives a user operation and registers the function object corresponding to the business function used to handle the user operation in the second thread, when the second application triggers the execution of the business function, the first application will pass the user operation to the business function so that the business function runs based on the user operation and outputs the execution result data.
[0154] For example, the pointer in the function object of the game scene editor points to the memory address of the operation function in the game scene editor. After the game engine calls this function object, the game scene editor passes the user operation information it has obtained to the operation function, so that the game engine can obtain the execution result data of the operation function. For example, the user operation information is the human-computer interaction operation of the user in the user interface of the game scene editor, and the execution result data includes the operation instruction to create a cube in the virtual environment, as well as the position data of the cube in the virtual environment. After obtaining the execution result data, the game engine can create the cube in the virtual environment according to the position data.
[0155] For example, the code for the class used to define the function object of the first application is as follows:
[0156]
[0157] The code above defines a class for the function object of the operation, which encapsulates a callback method. The second application, by calling this function object, can execute the callback method, thereby obtaining the pointer (FunctionPointer) to the business function (e.g., m_operator) pointed to by the callback method in the first application, and retrieving the execution result data of that business function, thus achieving data synchronization with the first application.
[0158] When the second application executes business logic that calls function objects in the function store, it invokes those function objects to synchronize data with the first application. Optionally, the second application may call the first application's function object if a trigger condition is met during execution. For example, if the second application has business logic for function execution, and this logic is executed during runtime, the trigger condition is met, and the second application will call the function object registered by the first application in the function store. Optionally, the business logic in the second application and the order in which it is executed are set by the developers.
[0159] For example, the second application has business logic A, business logic B, and business logic C. During runtime, the second application will run these three business logics in a loop. Business logic B is used by the second application to execute a function object that calls the first application. When the second application runs business logic B, it can be considered that a trigger condition has been met. At this time, the second application will call the function object of the first application to obtain the data that the first application needs to synchronize with the second application.
[0160] In a specific example Figure 6 This is a flowchart illustrating the operation of a game scene editor and game engine provided in an exemplary embodiment of this application. Figure 6 As shown:
[0161] In step S1, after the game scene editor 601 starts, business logic 1 notifies the game engine 602 to run, thereby initiating the game engine 602 to run. Since the game scene editor 601 starts the game engine 602, the current perception between the two is unidirectional.
[0162] In step S2, the game engine 602's business function 3 is responsible for allocating a function storage area, which records some function objects passed from the game scene editor 601. Afterwards, the game engine 602 will continue executing business function 4.
[0163] In step S3, the game scene editor 601 executes business function 2 (which may run in parallel with business function 4 of the game engine 602). Business function 2 needs to synchronize some data with the game engine 602. Since the game scene editor 601 manages the game engine 602, it is also aware of the function storage area in the game engine 602. Therefore, business function 2 can register function objects with the function storage area through an interface to synchronize data with the game engine 602.
[0164] In step S4, game engine 602 finishes executing business logic 4 and proceeds to the function execution business module. This business logic is responsible for processing the registered function objects in the function storage area, thereby synchronizing data with the business logic in game scene editor 601. Afterwards, game engine 602 continues executing its own business chain (business logic 5, business logic 7). At this point, game engine 602 only knows that there are some function objects waiting to be processed, but it is unaware of the specific business logic encapsulated within these function objects.
[0165] In steps S5 and S6, when the function object in the function storage area is executed by the game engine 602, it is actually notifying the game scene editor 601 to continue executing different business logic. These business logics, such as business logic 6, may be independent (not interacting with other business logics after execution). Alternatively, business logic 8 may be a non-independent business (interacting with other business logics after execution). After receiving the signal to continue execution, business logic 8 will continue to execute in the main flow and will be executed coherently with other business logics (business logic 9) until the program exits normally.
[0166] It should be noted that the method provided in this embodiment can also be executed by a second application. That is, the second application registers its function object with the first thread of the first application, and the first application obtains the operation instructions or data synchronized by the second application by calling the function object of the second application. In this case, the first application and the second application can synchronize operation instructions or data with each other without the need for mutual calls between the first application and the second application.
[0167] In summary, the method provided in this embodiment involves a first application registering a function object in a second application. The second application can trigger the execution of a business function in the first application by calling this function object. Since this business function encapsulates the operation instructions from the first application to the second application for synchronization, inter-thread operation instruction synchronization is achieved. Because the second application obtains the required synchronization instructions by executing the business function in the first application, accurate acquisition of the required synchronization instructions is guaranteed. Therefore, the first application can execute subsequent business logic immediately after registering the function object without additional waiting. In the case where the first application is a game scene editor, this avoids the problem of the game scene editor continuously waiting during the synchronization of operation instructions, which could prevent the execution of subsequent business logic.
[0168] Furthermore, when implementing operation instructions or data synchronization between different threads, only the function object needs to be registered in a single thread. There's no need to develop synchronization interfaces for each thread, and no need for calls between the two threads. This effectively reduces the number of interfaces that need to be provided between the two threads and solves the problem of high coupling between threads caused by calls between synchronized threads.
[0169] In addition, operations that require data synchronization are packaged into function objects, which are uniformly registered by the first application to the function storage area of the second thread of the second application. The second application calls them at specific times, which effectively reduces the number of interfaces that need to be provided between the two threads, while reducing code complexity, improving code maintainability and development efficiency, and reducing the coupling between threads.
[0170] Furthermore, compared to related technologies that require multiple calls to the thread-provided interface when synchronizing multiple data points, the method provided in this embodiment, through a second application calling a function object, can obtain the execution result data of multiple business functions in the first application pointed to by multiple pointers of the function object in a single call. In other words, multiple data points requiring synchronization can be obtained with a single call to the function object, simplifying the data synchronization process.
[0171] Furthermore, encapsulating the business logic for data synchronization through function objects can accelerate the coding efficiency of business developers. During data synchronization, they only need to focus on the business functions that the current application needs to implement, without needing to worry about the running state of other threads (applications). The first and second threads do not need to call each other during data synchronization, which also reduces code complexity and error potential.
[0172] It should be noted that the order of the method steps provided in the embodiments of this application can be appropriately adjusted, and the steps can also be added or removed as appropriate. Any method variations that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the protection scope of this application, and therefore will not be elaborated further.
[0173] Figure 7 This is a schematic diagram of the structure of an inter-thread operation instruction synchronization device provided in an exemplary embodiment of this application. For example... Figure 7 As shown, the device includes:
[0174] The running module 701 is used to start running in the second thread according to the invocation instruction of the first application, the first application is used to run in the first thread, and the first thread is different from the second thread;
[0175] The receiving module 702 is used to receive the function object of the first application registered by the first application in the second thread, wherein the function object of the first application is used to indicate the business function in the first application;
[0176] The calling module 703 is used to call the function object of the first application to trigger the execution of the business function indicated by the function object of the first application, wherein the business function encapsulates the operation instructions for the first application to synchronize with the second application.
[0177] In an optional design, the function object of the first application encapsulates the memory address of the business function; the calling module 703 is used to:
[0178] The function object of the first application is invoked to obtain the business function through the memory address and trigger the execution of the business function.
[0179] In an optional design, the function object of the first application encapsulates a callback function, and the callback function corresponds to at least one pointer; the calling module 703 is used for:
[0180] Invoke the function object of the first application to run the callback function;
[0181] Based on the at least one pointer corresponding to the callback function, the business function indicated by the at least one pointer in the first application is triggered and executed;
[0182] Each of the at least one pointer points to the memory address of a business function in the first application.
[0183] In an optional design, the receiving module 702 is used for:
[0184] Create a function storage area in the second thread;
[0185] Receive a function object from the first application, the function object being registered by the first application in the function storage area of the second thread.
[0186] In an optional design, the device provides a registration interface; the receiving module 702 is used for:
[0187] The first application's function object is received through the registration interface. The function object is registered by the first application in the function storage area of the second thread through the registration interface.
[0188] In an optional design, the business function is used to synchronize data; the calling module 703 is used to call the function object of the first application to trigger the execution of the business function indicated by the function object of the first application, and obtain the execution result data of the business function.
[0189] Figure 8 This is a schematic diagram of the structure of an inter-thread operation instruction synchronization device provided in an exemplary embodiment of this application. For example... Figure 8 As shown, the device includes:
[0190] Initiation module 801 is used to initiate and run a second application during the operation of the device, the device being used to run a first thread;
[0191] Registration module 802 is used to register the function object of the device in the second thread corresponding to the second application. The second application is used to run in the second thread. The first thread is different from the second thread. The function object is used to indicate the business function in the device.
[0192] In the case where the second application calls the function object of the device, the function object is used to trigger the execution of the business function, which encapsulates the operation instructions from the first application to the second application.
[0193] In an optional design, the registration module 802 is used for:
[0194] In the function storage area of the second thread corresponding to the second application, the function object of the device is registered, and the function storage area is created by the second application.
[0195] In an optional design, the second application provides a registration interface; the registration module 802 is used for:
[0196] By calling the registration interface, the function object of the device is registered in the function storage area of the second thread corresponding to the second application.
[0197] In an optional design, the business function is used to process user operations in the device; the registration module 802 is used to:
[0198] In response to receiving the user operation, the function object of the device is registered in the second thread corresponding to the second application;
[0199] like Figure 9 As shown, the device further includes:
[0200] The transmission module 803 is used to respond to the business function triggering operation by passing the user operation to the business function, so that the business function runs based on the user operation and outputs the operation result data.
[0201] It should be noted that the inter-thread operation instruction synchronization device provided in the above embodiments is only an example of the division of the above functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the inter-thread operation instruction synchronization device and the inter-thread operation instruction synchronization method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.
[0202] Embodiments of this application also provide a computer device, which includes a processor and a memory. The memory stores at least one instruction, at least one program, code set, or instruction set. The at least one instruction, at least one program, code set, or instruction set is loaded and executed by the processor to implement the thread operation instruction synchronization method provided in the above-described method embodiments.
[0203] For example, Figure 10 This is a schematic diagram of the structure of a computer device provided in an exemplary embodiment of this application.
[0204] The computer device 1000 includes a central processing unit (CPU) 1001, a system memory 1004 including random access memory (RAM) 1002 and read-only memory (ROM) 1003, and a system bus 1005 connecting the system memory 1004 and the CPU 1001. The computer device 1000 also includes a basic input / output system (I / O system) 1006 to facilitate information transfer between various components within the computer device, and a mass storage device 1007 for storing the operating system 1013, application programs 1014, and other program modules 1015.
[0205] The basic input / output system 1006 includes a display 1008 for displaying information and an input device 1009 for user input, such as a mouse or keyboard. Both the display 1008 and the input device 1009 are connected to the central processing unit 1001 via an input / output controller 1010 connected to the system bus 1005. The basic input / output system 1006 may also include the input / output controller 1010 for receiving and processing input from multiple other devices such as a keyboard, mouse, or electronic stylus. Similarly, the input / output controller 1010 also provides output to a display screen, printer, or other types of output devices.
[0206] The mass storage device 1007 is connected to the central processing unit 1001 via a mass storage controller (not shown) connected to the system bus 1005. The mass storage device 1007 and its associated computer-readable storage media provide non-volatile storage for the computer device 1000. That is, the mass storage device 1007 may include computer-readable storage media (not shown), such as a hard disk or a compact disc read-only memory (CD-ROM) drive.
[0207] Without loss of generality, the computer-readable storage medium may include computer storage media and communication media. Computer storage media include volatile and non-volatile, removable and non-removable media implemented using any method or technology for storing information such as computer-readable storage instructions, data structures, program modules, or other data. Computer storage media include RAM, ROM, erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other solid-state storage devices, CD-ROM, digital versatile disc (DVD) or other optical storage, magnetic tape cassettes, magnetic tape, disk storage, or other magnetic storage devices. Of course, those skilled in the art will recognize that the computer storage medium is not limited to the above-mentioned types. The system memory 1004 and mass storage device 1007 described above can be collectively referred to as memory.
[0208] The memory stores one or more programs, which are configured to be executed by one or more central processing units 1001. The one or more programs contain instructions for implementing the above method embodiments, and the central processing unit 1001 executes the one or more programs to implement the methods provided by the various method embodiments described above.
[0209] According to various embodiments of this application, the computer device 1000 can also be connected to a remote computer device on a network, such as the Internet. That is, the computer device 1000 can be connected to the network 1012 via the network interface unit 1011 connected to the system bus 1005, or the network interface unit 1011 can be used to connect to other types of networks or remote computer device systems (not shown).
[0210] The memory further includes one or more programs stored in the memory, and the one or more programs include steps performed by a computer device in the methods provided in the embodiments of this application.
[0211] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the above-described apparatus and each module can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0212] This application also provides a computer-readable storage medium storing at least one instruction, at least one program, code set, or instruction set. When the at least one instruction, at least one program, code set, or instruction set is loaded and executed by the processor of a computer device, the thread operation instruction synchronization method provided in the above-described method embodiments is implemented.
[0213] This application also provides a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the inter-thread operation instruction synchronization method provided in the above-described method embodiments.
[0214] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0215] The above description is merely an optional embodiment of this application and is not intended to limit this application. Any modifications, equivalent switching, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
[0216] The above description is merely an optional embodiment of this application and is not intended to limit this application. Any modifications, equivalent switching, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A system for synchronizing operation instructions between threads, characterized in that, The system includes: a first application and a second application, wherein the first application is used to run on a first thread and the second application is used to run on a second thread, and the first thread is different from the second thread; The first application is used to invoke and run the second application during runtime; The second application is used to create a function storage area in the second thread; The first application is further configured to register a function object of the first application in the function storage area of the second thread corresponding to the second application. The function object of the first application is used to indicate the business function in the first application, and the function object of the first application encapsulates the memory address of the business function. The second application is further configured to call the function object of the first application to trigger the execution of the business function indicated by the function object of the first application, wherein the business function encapsulates the operation instructions for the first application to synchronize with the second application.
2. The system according to claim 1, characterized in that, The second application is used to call the function object of the first application to obtain the business function through the memory address and trigger the execution of the business function.
3. The system according to claim 2, characterized in that, The first application's function object encapsulates a callback function, and each callback function corresponds to at least one pointer; the second application is used for: Invoke the function object of the first application to run the callback function; Based on the at least one pointer corresponding to the callback function, the business function indicated by the at least one pointer in the first application is triggered and executed; Each of the at least one pointer points to the memory address of a business function in the first application.
4. The system according to any one of claims 1 to 3, characterized in that, The second application provides a registration interface; The first application is configured to register its function object in the function storage area of the second thread by calling the registration interface.
5. The system according to claim 4, characterized in that, The second application is configured to create the function storage area in the second thread when it is invoked and run by the first application; The second application is also configured to clear the function storage area of the second thread upon termination of runtime.
6. The system according to any one of claims 1 to 3, characterized in that, The business function is used to synchronize data; The second application is further configured to call the function object of the first application to trigger the execution of the business function indicated by the function object of the first application, and obtain the execution result data of the business function.
7. The system according to claim 6, characterized in that, The business function is used to process user operations in the first application; The first application is configured to, in response to receiving the user operation, register a function object of the first application in the second thread corresponding to the second application; The first application is further configured to, in response to the business function triggering execution, pass the user operation to the business function so that the business function runs based on the user operation and outputs the execution result data.
8. The system according to any one of claims 1 to 3, characterized in that, The second application is also used to call the function object of the first application when the triggering conditions are met during operation.
9. The system according to any one of claims 1 to 3, characterized in that, The first application is a game scene editor, and the second application is a game engine. The game engine is used to perform rendering based on the data provided by the game scene editor.
10. A method for synchronizing operation instructions between threads, characterized in that, The method is applied to a second application, and the method includes: The application is launched and runs in the second thread according to the invocation instruction of the first application. The first application is used to run in the first thread, which is different from the second thread. Create a function storage area in the second thread; The first application receives a function object registered in the function storage area of the second thread. The function object of the first application is used to indicate the business function in the first application, and the function object of the first application encapsulates the memory address of the business function. The function object of the first application is invoked to trigger the execution of the business function indicated by the function object of the first application, the business function encapsulating the operation instructions of the first application to synchronize with the second application.
11. A method for synchronizing operation instructions between threads, characterized in that, The method is applied to a first application, and the method includes: During the execution of the first application, a second application is invoked and run, while the first application is used to run in the first thread; In the function storage area of the second thread corresponding to the second application, the function object of the first application is registered. The second application is used to run in the second thread. The first thread is different from the second thread. The function object is used to indicate the business function in the first application. The function object of the first application encapsulates the memory address of the business function. The function storage area is created by the second application in the second thread. In the case where the second application calls the function object of the first application, the function object is used to trigger the execution of the business function, which encapsulates the operation instructions for the first application to synchronize with the second application.
Citation Information
Patent Citations
Remote process calling method and device and computer device
CN107479985A
Data calling method and related product
CN113971096A
