A task processing method, apparatus, device, and storage medium

By unifying thread calls between the engine layer and the native layer in the main thread within a mobile application, and utilizing message loop execution units and thread communication tools, the stuttering problem caused by thread deadlock is resolved, thereby improving call performance and efficiency.

CN113918294BActive Publication Date: 2025-12-19DOUYIN VISION CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111181362.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-11
Publication Date
2025-12-19
Estimated Expiration
2041-12-19

AI Technical Summary

Technical Problem

When integrating third-party SDKs, improper thread calls between different functional layers in a mobile application can lead to thread deadlocks, which in turn cause stuttering issues.

Method used

By unifying thread calls between the engine layer and the native layer in the main thread, and utilizing message loop execution units and thread communication tools, the sending and receiving of task feedback information is realized, thus avoiding thread deadlock.

Benefits of technology

It effectively avoids thread deadlock, improves the performance and efficiency of calls between functional layers, and prevents application lag.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113918294B_ABST
    Figure CN113918294B_ABST
Patent Text Reader

Abstract

The present disclosure provides a task processing method and device, equipment and a storage medium, the method comprising: receiving a task call instruction sent by an engine layer, the task call instruction being used to call a target task of a native layer through a main thread of the engine layer; in the process of calling the target task, obtaining a message loop execution unit of the main thread; in the case of receiving a task feedback instruction sent by the native layer for the task call instruction, sending task feedback information corresponding to the target task to the main thread based on the message loop execution unit; and the engine layer receives the task feedback information through the main thread. The present disclosure can avoid the problem of lag caused by mutual calling between the engine layer and the native layer.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the technical field of computer, and in particular, to a task processing method and device, equipment and a computer readable storage medium. BACKGROUND

[0002] At present, mobile applications expand business scenarios by integrating SDK (Software Development Kit), the purpose of using SDK is to quickly and efficiently complete product requirements, and to some extent, facilitate user use and reduce user learning cost. For example, game development engines need to integrate third-party SDK (such as login, payment, chat, real-time voice, etc.) to realize corresponding functions.

[0003] However, when integrating third-party SDK, the problem of mutual calling between different function layers in the same application will be involved, and in the prior art, since different function layers are implemented in different threads when calling each other, if thread control is improper, thread deadlock problem will be caused, and then causing the problem of lag. SUMMARY

[0004] The embodiments of the present disclosure at least provide a task processing method, device, equipment and storage medium, which can solve at least one of the above problems.

[0005] The embodiments of the present disclosure provide a task processing method, which comprises:

[0006] receiving a task calling instruction sent by an engine layer, the task calling instruction being used to call a target task of a native layer through a main thread of the engine layer;

[0007] In the process of calling the target task, a message loop execution unit of the main thread is acquired;

[0008] In the case of receiving a task feedback instruction sent by the native layer and corresponding to the task calling instruction, task feedback information corresponding to the target task is sent to the main thread based on the message loop execution unit; the task feedback information is received by the engine layer through the main thread.

[0009] In the embodiments of the present disclosure, the task feedback information corresponding to the target task is sent to the main thread based on the message loop execution unit acquired from the main thread, that is, by executing the threads of mutual calling between the engine layer and the native layer in one thread, the problem of thread deadlock caused by improper thread scheduling control can be avoided, and the problem of lag of the application program can be further avoided.

[0010] In an alternative embodiment, a bridge layer is present between the engine layer and the native layer, wherein the bridge layer is an intermediate layer for mutual invocation between the engine layer and the native layer; and the message loop execution unit of the main thread is acquired in the process of invoking the target task, including:

[0011] The message loop execution unit of the main thread is acquired in the process of invoking the target task based on the bridge layer;

[0012] An instance object of a thread communication tool is created, wherein the instance object of the thread communication tool is saved as a static variable;

[0013] The message loop execution unit is saved into the instance object of the thread communication tool;

[0014] The task feedback information corresponding to the target task is sent to the main thread based on the message loop execution unit, including:

[0015] The task feedback information corresponding to the target task is sent to the main thread based on the instance object of the thread communication tool.

[0016] In the embodiments of the present disclosure, the message loop execution unit is saved into the instance object of the thread communication tool, and the instance object of the thread communication tool is saved as a static variable, so that the message loop execution unit can be acquired from the memory at any time during the execution of the main thread.

[0017] In an alternative embodiment, the task feedback information corresponding to the target task is sent to the main thread based on the instance object of the thread communication tool, including:

[0018] The task feedback information corresponding to the target task is sent to the main thread based on a task dispatching method of the instance object of the thread communication tool.

[0019] In an alternative embodiment, the message loop execution unit of the main thread is acquired in the process of invoking the target task based on the bridge layer, including:

[0020] The instance object of the thread communication tool is determined to exist or not exist in the process of invoking the target task based on the bridge layer;

[0021] The message loop execution unit of the main thread is acquired in the case that the instance object of the thread communication tool does not exist.

[0022] In the embodiment of the present disclosure, since the calling between the two function layers is very frequent, before obtaining the message loop execution unit of the main thread, it can be firstly judged whether the instance object of the thread communication tool exists, which can ensure that the obtaining of the message loop execution unit of the main thread is only executed once, thereby reducing the system overhead, and improving the calling performance between the two function layers.

[0023] In an optional implementation, the sending, by the instance object of the thread communication tool, of the task feedback information corresponding to the target task to the main thread comprises:

[0024] judging whether the instance object of the thread communication tool exists;

[0025] in a case where the instance object of the thread communication tool exists, sending the task feedback information to the main thread.

[0026] In an optional implementation, the sending, by the instance object of the thread communication tool, of the task feedback information corresponding to the target task to the main thread further comprises:

[0027] in a case where the instance object of the thread communication tool does not exist, sending the task feedback information to a target thread of the native layer; wherein the target thread is determined by the type of the target task.

[0028] In the embodiment of the present disclosure, in a case where the instance object of the thread communication tool does not exist, the sending of the task feedback information to the target thread can further ensure the integrity of the execution flow of the scheme.

[0029] In an optional implementation, the development language of the engine layer is C# language, and the development language of the native layer is Java language.

[0030] The embodiment of the present disclosure further provides a task processing apparatus, which comprises:

[0031] a calling module, configured to receive a task calling instruction sent by an engine layer, the task calling instruction being used to call a target task of a native layer through a main thread of the engine layer;

[0032] an obtaining module, configured to obtain a message loop execution unit of the main thread in the process of calling the target task;

[0033] a dispatching module, configured to, in a case where a task feedback instruction sent by the native layer for the task calling instruction is received, send, based on the message loop execution unit, task feedback information corresponding to the target task to the main thread; the engine layer receives the task feedback information through the main thread.

[0034] In an optional implementation, the obtaining module is specifically configured to:

[0035] obtain a message loop execution unit of the main thread in a process of invoking the target task based on the bridge layer;

[0036] create an instance object of a thread communication tool, and save the instance object of the thread communication tool as a static variable;

[0037] save the message loop execution unit into the instance object of the thread communication tool.

[0038] In an optional implementation, the dispatching module is specifically configured to:

[0039] send task feedback information corresponding to the target task to the main thread based on the instance object of the thread communication tool.

[0040] In an optional implementation, the obtaining module is specifically configured to:

[0041] judge whether the instance object of the thread communication tool exists in a process of invoking the target task based on the bridge layer;

[0042] obtain a message loop execution unit of the main thread in a case where the instance object of the thread communication tool does not exist.

[0043] In an optional implementation, the dispatching module is specifically configured to:

[0044] send task feedback information corresponding to the target task to the main thread based on a task dispatching method of the instance object of the thread communication tool.

[0045] In an optional implementation, the dispatching module is specifically configured to:

[0046] judge whether the instance object of the thread communication tool exists;

[0047] send the task feedback information to the main thread in a case where the instance object of the thread communication tool exists.

[0048] In an optional implementation, the dispatching module is specifically configured to:

[0049] send the task feedback information to a target thread of the native layer in a case where the instance object of the thread communication tool does not exist, and the target thread is determined by a type of the target task.

[0050] The embodiment of the present disclosure further provides a computer device, comprising a processor, a memory and a bus, the memory stores machine readable instructions executable by the processor, when the computer device is running, the processor and the memory communicate through the bus, the machine readable instructions are executed by the processor to perform the steps in the task processing method.

[0051] The embodiment of the present disclosure further provides a computer readable storage medium, the computer readable storage medium stores a computer program, when the computer program is executed by the processor, the steps in the task processing method are executed.

[0052] In order to make the above objectives, characteristics and advantages of the present disclosure more apparent, clear and easy to understand, the following preferred embodiments are specifically described below, and the accompanying drawings are described in detail as follows. BRIEF DESCRIPTION OF DRAWINGS

[0053] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following will briefly introduce the drawings needed to be used in the embodiments, the drawings herein are incorporated into the description and form a part of the description, the drawings show the embodiments consistent with the present disclosure, and are used to illustrate the technical solutions of the present disclosure together with the description. It should be understood that the following drawings only show some embodiments of the present disclosure, and therefore should not be regarded as a limitation on the scope, and for those skilled in the art, other related drawings can also be obtained without creative labor on the basis of these drawings.

[0054] Figure 1 A flow chart of a task processing method provided by the embodiment of the present disclosure;

[0055] Figure 2 A schematic diagram of mutual invocation between an engine layer and a native layer provided by the embodiment of the present disclosure;

[0056] Figure 3 A flow chart of a message loop execution unit method for obtaining a main thread provided by the embodiment of the present disclosure;

[0057] Figure 4 A flow chart of another message loop execution unit method for obtaining a main thread provided by the embodiment of the present disclosure;

[0058] Figure 5 A flow chart of a task feedback information dispatching execution method provided by the embodiment of the present disclosure;

[0059] Figure 6 A structural diagram of a task processing device provided by the embodiment of the present disclosure;

[0060] Figure 7 A schematic diagram of an electronic device provided by the embodiment of the present disclosure. DETAILED DESCRIPTION

[0061] To make the objectives, technical solutions and advantages of the embodiments of the present disclosure clearer, the following will be combined with the accompanying drawings for the embodiments of the present disclosure to make a clear and complete description of the technical solutions in the embodiments of the present disclosure. Obviously, the described embodiments are only a part of the embodiments of the present disclosure and not all the embodiments. The components of the embodiments of the present disclosure generally described and shown in the accompanying drawings can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the accompanying drawings is not intended to limit the scope of the claimed present disclosure, but only represents selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without creative work fall within the scope of protection of the present disclosure.

[0062] It should be noted that: similar reference numerals and letters represent similar items in the following drawings, and therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings.

[0063] The term "and / or" herein only describes an association relationship and means that there can be three relationships, for example, A and / or B can mean that A exists alone, A and B exist together, and B exists alone. In addition, the term "at least one" herein means any one of a plurality or any combination of at least two of a plurality, for example, including at least one of A, B, and C can mean including any one or more elements selected from the set consisting of A, B, and C.

[0064] At present, mobile applications expand business scenarios by integrating SDK (Software Development Kit). The purpose of using SDK is to quickly and efficiently complete product requirements and to some extent, facilitate user use and reduce user learning costs. For example, game development engines need to integrate third-party SDKs (such as login, payment, chat, real-time voice, etc.) to realize corresponding functions.

[0065] However, when integrating third-party SDKs, the problem of mutual calling between different functional layers in the same application will be involved. In the prior art, since different functional layers are implemented in different threads when calling each other, improper thread control in the process of mutual calling will cause thread deadlock problems, and further cause the problem of lag.

[0066] Based on the above research, the task processing method provided in the embodiments of the present disclosure can unify the threads of mutual calls between the engine layer and the native layer in the main thread, can avoid the problem of thread deadlock between different threads, and further avoid the problem of lag caused by thread deadlock, so as to improve the calling performance and efficiency between the two functional layers.

[0067] The defects of the above solutions are the results of the inventors after practice and careful research, therefore, the discovery process of the above problems and the solutions proposed by the present disclosure to the above problems in the following should be the contributions of the inventors to the present disclosure.

[0068] In order to facilitate the understanding of the present embodiment, first, a task processing method disclosed in the embodiments of the present disclosure is introduced in detail, and the execution subject of the task processing method provided in the embodiments of the present disclosure is generally a computer device with certain computing power, which includes, for example, a terminal device or a server or other processing device, and the terminal device can be a user equipment (User Equipment, UE), a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (Personal Digital Assistant, PDA), a handheld device, a computing device, a vehicle-mounted device, a wearable device, etc. In some possible implementation manners, the task processing method can be realized by calling computer readable instructions stored in the memory by the processor.

[0069] The task processing method provided in the embodiments of the present disclosure is described below taking the terminal device as an example.

[0070] Please refer to Figure 1 , Figure 1 The flowchart of the task processing method provided in the embodiments of the present disclosure is shown in FIG. 1. As shown in FIG. 1, the task processing method provided in the embodiments of the present disclosure includes the following steps S101-S103: Figure 1

[0071] S101, receiving a task calling instruction sent by an engine layer, the task calling instruction being used to call a target task of a native layer through a main thread of the engine layer.

[0072] In this step, the engine layer sends a task calling instruction to the native layer, and when the native layer receives the task calling instruction sent by the engine layer, the target task of the native layer can be called through the main thread of the engine layer, wherein the development language of the engine layer is different from the development language of the native layer.

[0073] ​In some embodiments, the development language of the engine layer is C# language, and the development language of the native layer is Java language. In other embodiments, the languages of the engine layer and the native layer can also be other languages, such as C / C++, Delphi, python, Visual Basic, etc., which are not limited herein, as long as the development languages of the engine layer and the native layer are different.

[0074] The target task includes a third-party software development kit (SDK) required by the engine layer, and the SDK can implement the functions of login, payment, chat, and real-time voice of the game.

[0075] In actual applications, the engine layer and the native layer are developed separately in the development stage, and both of them run in the Android operating system in the running stage.

[0076] In addition, in some embodiments, there is a bridge layer between the engine layer and the native layer, wherein the bridge layer is an intermediate layer for mutual calling between the engine layer and the native layer.

[0077] For example, please refer to Figure 2 , Figure 2 the mutual calling schematic diagram of the engine layer and the native layer provided by the embodiments of the present disclosure. As shown in Figure 2 , the development language of the engine layer is C# language, the development language of the native layer is Java language, and the mutual calling between the engine layer and the native layer is realized through the bridge layer. Wherein, the threads of the engine layer calling the native layer are converged to the main thread, and the main thread is the rendering thread of the engine layer.

[0078] In addition, in the process of the engine layer calling the native layer, the main thread executes the first closing method handleMsgFromUnity of the bridge layer, and realizes the communication with the native layer through the custom bridge method in the bridge layer, wherein the first closing method handleMsgFromUnity is an entry method in the bridge layer when the engine layer calls the native layer.

[0079] S102, in the process of calling the target task, the message loop execution unit of the main thread is obtained.

[0080] In this step, the message loop execution unit, i.e. Looper, can obtain the Looper of the main thread from the main thread when the main thread of the engine layer calls the target task of the native layer.

[0081] The Looper is a Looper of a thread in the Android system, each thread has a corresponding Looper, which can continuously read messages from the message queue and perform corresponding operations.

[0082] The embodiment of the disclosure provides further description for step S102, please refer to Figure 3 , Figure 3 The embodiment of the disclosure provides a flowchart of a method for obtaining a message loop execution unit of a main thread.

[0083] As shown in Figure 3 The method for obtaining a message loop execution unit of a main thread provided by the embodiment of the disclosure includes steps S1021-S1023:

[0084] S1021, based on the bridge layer, obtaining the message loop execution unit of the main thread in the process of calling the target task of the native layer.

[0085] In this step, based on the bridge layer between the engine layer and the native layer, first obtain the Looper of the main thread in the process of calling the target task of the native layer by the engine layer.

[0086] Specifically, please refer to Figure 2 Since the thread of the engine layer calling the native layer converges to the main thread, the main thread is the rendering thread of the engine layer, and the main thread converges to the first convergence method handleMsgFromUnity in the bridge layer, so the Looper of the main thread can be obtained in the calling process of the handleMsgFromUnity method.

[0087] The Java code for obtaining the message loop execution unit of the main thread is as follows:

[0088] Looper looper=Looper.myLooper();

[0089] S1022, creating an instance object of a thread communication tool, wherein the instance object of the thread communication tool is saved in a static variable.

[0090] In this step, after obtaining the Looper, an instance object of a thread communication tool is created, which is used to save the Looper, wherein the instance object of the thread communication tool is saved in the form of a static variable, and the thread communication tool Handler is an inter-thread communication mechanism provided by the Android system, which can be used in combination with the message loop execution unit to control the execution of a task in a thread.

[0091] For example, the Java code for creating an instance object sEngineMainHandler of the thread communication tool is as follows:

[0092] sEngineMainHandler = new Handler();

[0093] S1023, save the message loop execution unit to the instance object of the thread communication tool.

[0094] In this step, the instance object of the thread communication tool, i.e., sEngineMainHandler, saves the acquired Looper to the created sEngineMainHandler.

[0095] For example, the Java code for assigning the Looper to the created instance object sEngineMainHandler of the thread communication tool is as follows:

[0096] sEngineMainHandler = new Handler(looper);

[0097] S103, in the case where the task feedback instruction for the task calling instruction sent by the native layer is received, based on the message loop execution unit, the task feedback information corresponding to the target task is sent to the main thread; the engine layer receives the task feedback information through the main thread.

[0098] In this step, after the native layer receives the task calling instruction sent by the engine layer, the native layer calls back the feedback information corresponding to the target task to the engine layer, and in the case where the task feedback instruction sent by the native layer is received, based on the message loop execution unit obtained from the main thread, the task feedback information corresponding to the target task can be sent to the main thread.

[0099] The task feedback information can include a third-party software development kit (SDK) required by the engine layer, a result feedback of a method called by the engine layer to the native layer, and / or an event listening sent by the native layer, wherein the event listening is a listening mechanism set to enable the engine layer to timely perceive the message sent by the native layer.

[0100] For example, the event listening is illustrated. The engine layer needs to perceive the native layer in time that a new message arrives, and the native layer needs to use the event named onMessageChange to notify the engine layer. The process is that the engine layer registers an event listening to the native layer. That is, when the native layer receives a new message, the native layer sends the notification named onMessageChange to the engine layer. Thus, the engine layer can perceive the new message in time.

[0101] For example, the event listening is illustrated. The engine layer needs to perceive the native layer in time that a new message arrives, and the native layer needs to use the event named onMessageChange to notify the engine layer. The process is that the engine layer registers an event listening to the native layer. That is, when the native layer receives a new message, the native layer sends the notification named onMessageChange to the engine layer. Thus, the engine layer can perceive the new message in time. Figure 2 In the process of calling the engine layer by the native layer, the task feedback information is sent to the bridge layer by calling the callBackResult method and the sendEvent method, and the X thread executes the second closing method callEngine of the bridge layer, and the task feedback information corresponding to the target task is sent to the main thread based on the message loop execution unit, wherein the X thread is determined by the target task.

[0102] It can be understood that, in some embodiments, according to the foregoing, since the obtained Looper is saved in the created sEngineMainHandler, for step S103, specifically, it can include step S1031 (see Figure 4 ): the task feedback information corresponding to the target task is sent to the main thread based on the task dispatching method of the instance object of the thread communication tool.

[0103] For example, when the native layer calls the engine layer, the task feedback information corresponding to the target task is sent to the main thread based on the task dispatching method post of the created instance object sEngineMainHandler of the thread communication tool.

[0104] For example, the event listening is illustrated. The engine layer needs to perceive the native layer in time that a new message arrives, and the native layer needs to use the event named onMessageChange to notify the engine layer. The process is that the engine layer registers an event listening to the native layer. That is, when the native layer receives a new message, the native layer sends the notification named onMessageChange to the engine layer. Thus, the engine layer can perceive the new message in time. Figure 2 Since the SDKs for calling the engine layer by the native layer are different, the calling thread when the native layer calls the engine layer is affected by the SDK, so that the thread for calling the engine layer by the native layer is uncertain, but any thread for calling the engine layer by the native layer will call the second closing method callEngine of the bridge layer. Therefore, when the second closing method callEngine is executed, the task feedback information corresponding to the target task can be sent to the main thread based on the post method of the instance object sEngineMainHandler of the thread communication tool, wherein the second closing method callEngine is another closing method in the bridge layer when the native layer calls the engine layer.

[0105] It should be particularly noted that Figure 2The dispatch event and the result feedback callback of the engine layer calling the method of the native layer shown in the method are implemented in the X thread, and then, when the X thread executes to the second closing method callEngine, the task feedback information corresponding to the target task is sent to the main thread based on the post method of the instance object of the thread communication tool.

[0106] Referring to Figure 4 As shown in the flowchart, another method for obtaining the message loop execution unit of the main thread is provided in the embodiment of the present disclosure. In the method, steps S1011-S1012 are different from those shown in the method. Figure 3 In the embodiment, step S1021 includes the following steps S10211-S10212:

[0107] S10211, based on the bridge layer, it is judged whether the instance object of the thread communication tool exists in the process of calling the target task; if not, step S10212 is executed; if yes, step S1031 is executed.

[0108] S10212, in the case where the instance object of the thread communication tool does not exist, the message loop execution unit of the main thread is obtained.

[0109] In this step, in order to reduce system overhead and improve the calling performance between two functional layers, before obtaining the Looper of the main thread, based on the bridge layer, in the process of calling the target task, it can be first judged whether the sEngineMainHandler exists, if it exists, the Looper of the main thread can be directly executed through the sEngineMainHandler, if it does not exist, the Looper of the main thread is further obtained.

[0110] Referring to Figure 5 As shown in the flowchart, a method for dispatching and executing task feedback information is provided in the embodiment of the present disclosure. In some embodiments, step S1031 includes the following steps S10311-S10313:

[0111] S10311, it is judged whether the instance object of the thread communication tool exists; if yes, step S10312 is executed; if not, step S10313 is executed.

[0112] In this step, since in the embodiments of the present disclosure, it is required to implement the calling between the two function layers in one thread based on the sEngineMainHandler, when the native layer calls the engine layer, it can be firstly judged whether the sEngineMainHandler exists, if it exists, the task feedback information corresponding to the target task can be directly sent to the main thread according to the existing sEngineMainHandler in the calling process, if it does not exist, step S10313 is executed.

[0113] S10312, based on the task dispatching method of the instance object of the thread communication tool, the task feedback information corresponding to the target task is sent to the main thread.

[0114] In this step, in the case that the instance object of the thread communication tool exists, the task dispatching Post method of sEngineMainHandler is executed, and sEngineMainHandler can automatically execute the Looper it saves, so that the task feedback information corresponding to the target task can be sent to the main thread.

[0115] S10313, the task feedback information is sent to the target thread of the native layer; wherein the target thread is determined by the type of the target task.

[0116] It can be understood that if the task feedback information cannot be sent to the main thread before the task dispatching (Post) method of sEngineMainHandler is executed in the case that sEngineMainHandler does not exist, in order to enable the native layer to call the engine layer, the task feedback information needs to be sent to the target thread of the native layer.

[0117] The target thread of the native layer is an uncertain thread of the native layer calling the engine layer, which is determined by the type of the target task, that is, the aforementioned X thread. For example, the target thread of the native layer can be determined according to the SDK internal implementation of the native layer, which can be other asynchronous threads or the Android main thread.

[0118] The task processing method provided by the embodiments of the present disclosure sends the task feedback information corresponding to the target task to the main thread based on the message loop execution unit obtained from the main thread, so as to realize the unification of the threads of the mutual calling between the engine layer and the native layer in the main thread, which can avoid the problem of thread deadlock from the root, and further avoid the problem of lag caused by thread deadlock, and can improve the calling performance and efficiency between the engine layer and the native layer.

[0119] Those skilled in the art can understand that, in the above method of the specific embodiment, the writing order of each step does not mean a strict execution order and does not constitute any limitation on the implementation process, and the specific execution order of each step should be determined according to its function and possible internal logic.

[0120] Based on the same inventive concept, the present embodiment also provides a task processing device corresponding to the task processing method. Since the device in the present embodiment solves problems in a similar principle to the above-mentioned task processing method of the present embodiment, the implementation of the device can be referred to the implementation of the method, and the repeated parts will not be described here.

[0121] Please refer to Figure 6 , Figure 6 The structural diagram of a task processing device provided in the present embodiment.

[0122] As shown in Figure 6 The task processing device 600 provided in the present embodiment comprises:

[0123] The calling module 610 is configured to receive a task calling instruction sent by an engine layer, and the task calling instruction is used to call a target task of a native layer through a main thread of the engine layer.

[0124] The obtaining module 620 is configured to obtain a message loop execution unit of the main thread in the process of calling the target task.

[0125] The dispatching module 630 is configured to, in the case of receiving a task feedback instruction sent by the native layer and corresponding to the task calling instruction, send task feedback information corresponding to the target task to the main thread based on the message loop execution unit, and the engine layer receives the task feedback information through the main thread.

[0126] In an optional implementation, the obtaining module 620 is specifically configured to:

[0127] Obtain a message loop execution unit of the main thread in the process of calling the target task based on the bridge layer.

[0128] Create an instance object of a thread communication tool, and the instance object of the thread communication tool is saved as a static variable.

[0129] Save the message loop execution unit into the instance object of the thread communication tool.

[0130] In an optional implementation, the dispatching module 630 is specifically configured to:

[0131] Send the task feedback information corresponding to the target task to the main thread based on the instance object of the thread communication tool.

[0132] In an optional implementation, the obtaining module 620 is specifically configured to:

[0133] Based on the bridge layer, determine whether the instance object of the thread communication tool exists in the process of invoking the target task.

[0134] In the case where the instance object of the thread communication tool does not exist, obtain a message loop execution unit of the main thread.

[0135] In an optional implementation, the dispatching module 630 is specifically configured to:

[0136] Based on a task dispatching method of the instance object of the thread communication tool, send task feedback information corresponding to the target task to the main thread.

[0137] In an optional implementation, the dispatching module 630 is specifically configured to:

[0138] Determine whether the instance object of the thread communication tool exists.

[0139] In the case where the instance object of the thread communication tool exists, send the task feedback information to the main thread.

[0140] In an optional implementation, the dispatching module 630 is specifically configured to:

[0141] In the case where the instance object of the thread communication tool does not exist, send the task feedback information to a target thread of the native layer; the target thread is determined by the type of the target task.

[0142] The description of the processing procedure of each module in the apparatus and the interaction procedure between the modules can refer to the related description in the above method embodiments, and will not be described in detail here.

[0143] Based on the same technical concept, the present disclosure also provides an electronic device. Referring to FIG. 7, Figure 7 As shown in FIG. 7, the electronic device 700 provided by the present disclosure includes a processor 701, a memory 702, and a bus 703. The memory 702 is used to store execution instructions, including an internal memory 7021 and an external memory 7022. The internal memory 7021 is also called an internal memory, which is used to temporarily store operation data in the processor 701 and exchange data with the external memory 7022 such as a hard disk. The processor 701 exchanges data with the external memory 7022 through the internal memory 7021.

[0144] In the embodiments of the present application, the memory 702 is specifically used for storing application program codes for executing the scheme of the present application, and is controlled to execute by the processor 701. That is, when the electronic device 700 is running, the processor 701 and the memory 702 communicate through the bus 703, so that the processor 701 executes the application program codes stored in the memory 702, and further executes the method in any of the foregoing embodiments.

[0145] The processor 701 can be an integrated circuit chip having a processing capability of signals. The processor mentioned above can be a general processor, including a central processing unit (CPU), a network processor (NP), etc.; or can be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The disclosed methods, steps and logic block diagrams in the embodiments of the present application can be implemented or executed by the processor. The general processor can be a microprocessor or the processor can also be any conventional processor.

[0146] The memory 702 can be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), etc.

[0147] It can be understood that the structure shown in the embodiments of the present application does not constitute a specific limitation to the electronic device 700. In some other embodiments of the present application, the electronic device 700 can include more or fewer components than those shown, or combine some components, or split some components, or different arrangement of components. The components shown can be implemented in hardware, software or a combination of software and hardware.

[0148] The embodiments of the present disclosure also provide a computer readable storage medium, and the computer readable storage medium stores a computer program. When the computer program is run by a processor, the steps of the task processing method described in the method embodiments are executed. The storage medium can be a volatile or non-volatile computer readable storage medium.

[0149] The embodiment of the present disclosure further provides a computer readable storage medium, and the computer readable storage medium stores a computer program. When the computer program is run by a processor, the steps of the task processing method described in the above method embodiment are executed. The storage medium can be a volatile or non-volatile computer readable storage medium.

[0150] The embodiment of the present disclosure further provides a computer program product, and the computer program product carries a program code. The program code includes instructions for executing the steps of the task processing method described in the above method embodiment. For details, refer to the above method embodiment, which will not be described here.

[0151] The computer program product can be specifically implemented by hardware, software or a combination thereof. In an optional embodiment, the computer program product is specifically embodied as a computer storage medium, and in another optional embodiment, the computer program product is specifically embodied as a software product, such as a software development kit (SDK) and the like.

[0152] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described system and terminal can refer to the corresponding process in the above method embodiment, which will not be described here. In several embodiments provided by the present disclosure, it should be understood that the disclosed system, terminal and method can be implemented by other ways. The terminal embodiments described above are only schematic, for example, the division of the units is only a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be through some communication interface, or indirect coupling or communication connection between the units, which can be electrical, mechanical or other forms.

[0153] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, that is, they can be located in one place, or can be distributed on a plurality of network units. According to actual needs, some or all of the units can be selected to achieve the purpose of the embodiment.

[0154] In addition, each functional unit in each embodiment of the present disclosure can be integrated in one processing unit, or each unit can exist physically, or two or more units can be integrated in one unit.

[0155] If the functions are implemented in the form of software function units and sold or used as independent products, they can be stored in a nonvolatile computer readable storage medium executable by a processor. Based on this understanding, the technical solutions of the present disclosure essentially or the part that contributes to the prior art or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present disclosure. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (Read-Only Memory, ROM), a random access memory (Random Access Memory, RAM), a magnetic disk or an optical disk, and various media that can store program codes.

[0156] Finally, it should be noted that: the above-described embodiments are only specific embodiments of the present disclosure, used to illustrate the technical solutions of the present disclosure, and not to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art who is familiar with the technical field of the present disclosure can make modifications or easily think of changes to the technical solutions described in the foregoing embodiments within the technical scope disclosed by the present disclosure, or make equivalent replacements to some of the technical features. The modifications, changes or replacements do not cause the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be covered within the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be subject to the protection scope of the claims.

Claims

1. A task processing method characterized by, The method comprises the following steps: receiving a task calling instruction sent by an engine layer, the task calling instruction being used to call a target task of a native layer through a main thread of the engine layer, wherein the main thread is a rendering thread of the engine layer; acquiring a message loop execution unit of the main thread in the process of calling the target task based on a bridge layer between the engine layer and the native layer, wherein the message loop execution unit of the main thread is acquired in a first sink method calling process of the bridge layer, and the engine layer is uniformly sunk in the first sink method when calling the native layer; in the case that a task feedback instruction for the task calling instruction is received from the native layer, sending task feedback information corresponding to the target task to the main thread based on the message loop execution unit, wherein the task feedback information is received by the engine layer through the main thread, any thread of the engine layer calling the native layer calls a second sink method of the bridge layer, and the operation of the native layer calling the engine layer is uniformly dispatched and executed by an instance object of a thread communication tool in the second sink method, the instance object of the thread communication tool is used to save the acquired message loop execution unit, and the task feedback information corresponding to the target task is sent to the main thread based on a task dispatching method of the instance object of the thread communication tool.

2. The method of claim 1, wherein, The bridge layer is an intermediate layer for mutual calling between the engine layer and the native layer; the acquiring of the message loop execution unit of the main thread in the process of calling the target task based on the bridge layer comprises the following steps: acquiring the message loop execution unit of the main thread in the process of calling the target task based on the bridge layer; creating an instance object of the thread communication tool, wherein the instance object of the thread communication tool is saved as a static variable; saving the message loop execution unit into the instance object of the thread communication tool; the sending of the task feedback information corresponding to the target task to the main thread based on the message loop execution unit comprises the following steps: sending the task feedback information corresponding to the target task to the main thread based on the instance object of the thread communication tool.

3. The method of claim 2, wherein, The sending of the task feedback information corresponding to the target task to the main thread based on the instance object of the thread communication tool comprises the following steps: sending the task feedback information corresponding to the target task to the main thread based on the task dispatching method of the instance object of the thread communication tool.

4. The method according to claim 2 or 3, characterized in that, The acquiring of the message loop execution unit of the main thread in the process of calling the target task based on the bridge layer comprises the following steps: judging whether the instance object of the thread communication tool exists in the process of calling the target task based on the bridge layer; acquiring the message loop execution unit of the main thread in the case that the instance object of the thread communication tool does not exist.

5. The method of claim 2, wherein, The sending of the task feedback information corresponding to the target task to the main thread based on the instance object of the thread communication tool comprises the following steps: determining whether an instance object of the thread communication tool exists; in the case that the instance object of the thread communication tool exists, sending the task feedback information to the main thread.

6. The method of claim 5, wherein, The sending of the task feedback information corresponding to the target task to the main thread based on the instance object of the thread communication tool further includes: in the case that the instance object of the thread communication tool does not exist, sending the task feedback information to a target thread of the native layer, wherein the target thread is determined by the type of the target task.

7. The method of claim 1, wherein, The development language of the engine layer is C# language, and the development language of the native layer is Java language.

8. A task processing apparatus characterized by comprising: The method comprises: a calling module configured to receive a task calling instruction sent by the engine layer, the task calling instruction being used to call a target task of a native layer through a main thread of the engine layer, wherein the main thread is a rendering thread of the engine layer; an obtaining module configured to, based on a bridge layer between the engine layer and the native layer, obtain a message loop execution unit of the main thread in the process of calling the target task, wherein the message loop execution unit of the main thread is obtained in a first closing method calling process of the bridge layer, and the engine layer is uniformly closed in the first closing method when calling the native layer; a dispatching module configured to, in the case that a task feedback instruction sent by the native layer for the task calling instruction is received, send task feedback information corresponding to the target task to the main thread based on the message loop execution unit, and the engine layer receives the task feedback information through the main thread, wherein any thread of the engine layer calling the native layer calls a second closing method of the bridge layer in the second closing method, and the operation of the native layer calling the engine layer is uniformly dispatched and executed by an instance object of a thread communication tool in the second closing method, the instance object of the thread communication tool is used to save the obtained message loop execution unit, and the instance object of the thread communication tool is used to send the task feedback information corresponding to the target task to the main thread based on a task dispatching method of the instance object of the thread communication tool.

9. An electronic device, comprising: The method comprises: a processor, a memory and a bus, the memory stores machine readable instructions executable by the processor, when the electronic device is running, the processor and the memory communicate through the bus, and the machine readable instructions are executed by the processor to perform the steps of the task processing method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executed by the processor to perform the steps of the task processing method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Information communicating method and device

    CN108874554A