Data processing method and device, electronic equipment and storage medium
By binding the resource data of the target application instance in the target thread, the problem of frequent transfer of resource management identifiers in the single-threaded application framework is solved, the startup speed and operation efficiency of the application instance are improved, and the resource management process is simplified.
Patent Information
- Application Number
- CN202311206233.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-18
- Publication Date
- 2025-03-18
AI Technical Summary
In the single-threaded application framework, frequent transmission of resource management identifiers (IDs) to manage and access resources of multiple application instances, resulting in lengthy code, cumbersome operation process, and prone to data transmission errors, affecting the normal operation of application instances.
By binding the resource data of the target application instance in the target thread, directly accessing and using the resource data in the target thread, reducing dependence on resource management identifiers and simplifying the resource management process.
It improves the convenience of target thread accessing resource data, improves the execution speed and efficiency of starting target application instances, reduces the risk of code redundancy and data transmission errors, and reduces the burden on developers.
Smart Images

Figure CN119645580A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of software development and system design, and in particular to a data processing method and device, an electronic device, and a storage medium. Background Art
[0002] In the field of software development and system design, one or more application instances can be started using the application system framework, and the management of multiple application instances has gradually attracted the attention of R&D personnel. However, multiple application instances may contain the same or different resources, and it is very complicated to handle multiple application instances. In traditional solutions, these application instances are managed using unique resource management identifiers (IDs), which are passed around to identify and manage different instances.
[0003] For a single-threaded application framework, such as a graphical user interface (GUI) framework, for a thread that starts an application instance, when a function calls a resource, it is necessary to first pass an ID and then access the resources of the application instance through the ID. Therefore, in the process of running the target thread, the frequent passing of IDs due to function calls will not only cause the program code to be lengthy and repetitive, but also make the running process cumbersome and prone to data transmission errors, affecting the normal operation of the application instance. Summary of the invention
[0004] In order to overcome the problems existing in the related art, the present disclosure provides a data processing method and device, an electronic device, and a storage medium. Through the data processing method proposed in the present disclosure, the target application instance is run based on the resource data of the target application instance bound to the target thread, which not only reduces the situation where the resource data of the target application instance in the target thread needs to frequently transmit the resource management identifier, but also reduces the difficulty of managing the application instance resources through the resource management identifier.
[0005] In a first aspect of an embodiment of the present disclosure, a data processing method is provided, the method comprising:
[0006] In response to a start event for a target application instance, a target thread for running the target application instance is created based on a single-threaded application framework; wherein the target application instance is an instance for opening a target application program for running;
[0007] In the process of running the target thread, the target application instance is run based on the resource data of the target application instance bound to the target thread.
[0008] In some embodiments, running the target application instance based on the resource data of the target application instance bound to the target thread includes:
[0009] In the process of calling the function function, acquiring at least one resource data for executing the function function from the plurality of resource data of the target application instance bound to the target thread;
[0010] The target application instance is run based on the functional function and at least one resource data for executing the functional function.
[0011] In some embodiments, the programming language of the called function is different from the programming language of the target thread.
[0012] In some embodiments, the resource data of the target application instance includes target instance variables, and the method further includes:
[0013] The target instance variable is bound to the target thread based on a variable binding tool.
[0014] In some embodiments, the variable binding tool includes a thread local storage keyword, and the step of binding the target instance variable to the target thread based on the variable binding tool includes:
[0015] Based on the declaration of the target instance variable by the thread local storage keyword, the target instance variable is bound to the target thread.
[0016] In some embodiments, the variable binding tool includes a target class; and binding the target instance variable to the target thread based on the variable binding tool includes:
[0017] Initialize the target class; the target class is used to manage variables in the target thread;
[0018] Based on the declaration of the target instance variable by the target class, the target instance variable is bound to the target thread.
[0019] In some embodiments, the variable binding tool includes a target key; and binding the target instance variable to the target thread based on the variable binding tool includes:
[0020] Initializing the target key; the target key is used to manage variables in the target thread;
[0021] The target instance variable is bound to the target thread based on a key-value pair consisting of the target instance variable and the target key.
[0022] In some embodiments, the target instance variables include, but are not limited to: a renderer context, an event loop handle, an application development execution engine, a storage path of computer application code in a file system, and meta information of the target application.
[0023] According to a second aspect of the present disclosure, a data processing device is provided, the device comprising:
[0024] A thread creation module is configured to create a target thread for running the target application instance based on a single-threaded application framework in response to a start event for the target application instance; wherein the target application instance is an instance for opening a target application program for running;
[0025] The running module is configured to run the target application instance based on the resource data of the target application instance bound to the target thread during the running of the target thread.
[0026] In some embodiments, the resource data of the target application instance includes target instance variables, and the apparatus further includes:
[0027] The binding module is configured to bind the target instance variable to the target thread based on a variable binding tool.
[0028] According to a third aspect of the present disclosure, an electronic device is provided, the electronic device comprising:
[0029] processor;
[0030] a memory for storing processor-executable instructions;
[0031] Wherein, the processor is configured to execute the data processing method in the above-mentioned first aspect.
[0032] According to a fourth aspect of an embodiment of the present disclosure, a non-temporary computer-readable storage medium is provided. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the data processing method in the first aspect.
[0033] The technical solution provided by the embodiments of the present disclosure may have the following beneficial effects:
[0034] In the data processing method proposed in the embodiment of the present disclosure, the target application instance is run based on the resource data of the target application instance bound to the target thread, thereby improving the convenience of accessing the resource data during the operation of the target thread, and further improving the execution speed and efficiency of starting the target application instance; compared with the traditional solution of obtaining resource data through resource management identifiers, the present disclosure not only reduces the situation where the resource data of the target application instance needs to be frequently transmitted in the target thread, thereby reducing the problem of code redundancy and duplication and the problem of resource management identifiers being tampered with or destroyed during data transmission, but also further improves the success rate of application instance startup; the present disclosure also reduces the difficulty of managing application instance resources through resource management identifiers, thereby reducing the burden on developers and improving the running efficiency of applications.
[0035] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0037] Figure 1 A data processing method according to an exemplary embodiment is shown in FIG. Figure 1 ;
[0038] Figure 2 A data processing method according to an exemplary embodiment is shown in FIG. Figure 2 ;
[0039] Figure 3 A data processing method according to an exemplary embodiment is shown in FIG. Figure 3 ;
[0040] Figure 4 is a structural schematic diagram of a data processing device according to an exemplary embodiment;
[0041] Figure 5 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0042] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0043] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0044] In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present disclosure described herein can be implemented in an order other than that illustrated or described herein.
[0045] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which the present disclosure belongs. The terms used herein are only for the purpose of describing the embodiments of the present disclosure and are not intended to limit the present disclosure.
[0046] The present disclosure provides a data processing method. Figure 1 , Figure 1 A data processing method according to an exemplary embodiment is shown in FIG. Figure 1 ;like Figure 1 As shown, the data processing method proposed in the present disclosure can be implemented by the following steps:
[0047] Step 101, in response to a start event for a target application instance, creating a target thread for running the target application instance based on a single-threaded application framework; wherein the target application instance is an instance for opening a target application program for running;
[0048] Step 102: During the process of running the target thread, the target application instance is run based on the resource data of the target application instance bound to the target thread.
[0049] Here, the data processing method proposed in the present invention is applied in a scenario where a target application is run based on a single-threaded application framework. In this scenario, the present invention starts the target application instance based on the resource data bound to the target thread. In this way, not only is the need to frequently pass resource management identifiers when using the resource data of the target application instance in the target thread reduced, but the difficulty of managing application instance resources through resource management identifiers is also reduced.
[0050] Here, the single-threaded application framework that supports single-threaded services includes but is not limited to: Remote Dictionary Server (Redis) framework, Graphical User Interface (GUI) framework, Easy-Reactor framework, etc. The single-threaded application framework is applied to the operation, management and maintenance of the application. A target application instance is started and managed through a logical thread, and multiple logical threads are used to start multiple target application instances respectively; here, multiple logical threads can be executed in parallel without interfering with each other; multiple logical threads can also be executed concurrently, waiting for event response and execution through the task queue that communicates with the main thread opened by the application framework.
[0051] It should be noted that the single-threaded application framework in the present disclosure can run in electronic devices such as terminal devices or network servers. The single-threaded application framework can start multiple instances of a certain application based on multiple logical threads. In this case, the resource data corresponding to the multiple instances can be the same or different; the single-threaded application framework can also start instances corresponding to different applications based on multiple logical threads. In this case, each application is only allowed to start one instance in one electronic device, and the resource data of the multiple application instances are different.
[0052] In step 101, the start event for the target application instance can be based on the selection operation of the target application icon, or the jump operation to the target application, etc. The single-threaded application framework creates a target thread corresponding to the target application in response to the selection event or the jump event to complete the operation of the target application instance corresponding to the target application based on the target thread.
[0053] Exemplarily, the target application includes a social application; in response to a click operation based on a social application icon, a target thread is created based on a single-threaded application framework, such as a GUI framework, and the target thread is used to start an instance corresponding to the social application, namely, the target application instance, and before the target thread ends, operations such as text interaction, file sending and receiving, or voice interaction are completed in the target thread.
[0054] In step 102, during the process of running the target thread, the program provided by the application framework obtains resource data bound to the target thread, and uses the resource data to run the target application instance; here, running the target application instance includes but is not limited to page rendering, page updating, plug-in management and running, etc.
[0055] It should be noted that one or more application instances can be started during the operation of the target application. In the traditional solution, resource management identifiers (instance IDs) are used to manage multiple application instances in a single-threaded GUI framework. Each application instance is assigned a unique ID. All interactions with the application instance require passing the instance ID as a parameter to obtain the resources corresponding to the target application instance through the instance ID. Therefore, in the process of running the target thread, the code will be lengthy and repetitive due to the need to frequently pass the instance ID. In addition, there is the possibility of improper management of the instance ID, which may lead to data errors or inconsistencies. Therefore, the traditional solution of using instance IDs to manage resource data increases the burden on developers and reduces the efficiency of application operation.
[0056] Based on this, the embodiment of the present disclosure binds the resource of starting the target application instance to the target thread. Exemplarily, the present disclosure can allocate a private storage space for the target thread, and the resource data corresponding to the target application instance is placed in the private storage space. During the program running process, the resource data in the private storage space corresponding to the target thread is directly used, and the unique target application instance corresponding to it is run based on the resource; the present disclosure can also manage these resource data by providing an application program interface (Application Program Interface, API).
[0057] Here, in some actual examples, the resource data may include a plug-in running tool, and the plug-in corresponding to a module in the application instance is started by obtaining the plug-in running tool; in other actual examples, the resource data includes a file storage path, and the file data under the file storage path, such as image files, digital logos, etc., are called by accessing the file storage path to render the interface of the application instance.
[0058] In the data processing method proposed in the embodiment of the present disclosure, the target application instance is run based on the resource data of the target application instance bound to the target thread, thereby improving the convenience of accessing the resource data during the operation of the target thread, and further improving the execution speed and efficiency of starting the target application instance; compared with the traditional solution of obtaining resource data through resource management identifiers, the present disclosure not only reduces the situation where the resource data of the target application instance needs to be frequently transmitted in the target thread, thereby reducing the problem of code redundancy and duplication and the problem of resource management identifiers being tampered with or destroyed during data transmission, but also further improves the success rate of application instance startup; the present disclosure also reduces the difficulty of managing application instance resources through resource management identifiers, thereby reducing the burden on developers and improving the running efficiency of applications.
[0059] In some embodiments, see Figure 2 , Figure 2 A data processing method according to an exemplary embodiment is shown in FIG. Figure 2 ;like Figure 1 and Figure 2 As shown, running the target application instance based on the resource data of the target application instance bound to the target thread in step 102 can be implemented by the following steps:
[0060] Step 1021, in the process of calling the function function, obtaining at least one resource data for executing the function function from a plurality of resource data of the target application instance bound to the target thread;
[0061] Step 1022: Run the target application instance based on the function and at least one resource data for executing the function.
[0062] Here, the resource data corresponding to the target application instance bound in the target thread includes multiple ones, and one or more of the resource data can be used in different functional functions to complete different operation processes of running the target application instance.
[0063] In step 1021, the program for writing the function function includes an operation for obtaining at least one resource data. For example, at least one required resource data is directly accessed in the private storage space provided for the target thread through the acquisition operation. For another example, at least one resource data is obtained according to the corresponding API. In step 1022, the program for writing the function function performs operations on the at least one resource data obtained to complete at least one operation process of running the target application instance.
[0064] Exemplarily, during the current running process of the target thread, a function for page rendering is called to obtain at least one resource data, wherein the resource data includes a file storage path and a renderer context, etc. The file storage path is accessed to search for file data such as image files, digital identifiers, etc. under the file storage path, and the position, size, stacking relationship, etc. of the image files, digital identifiers, etc. file data are set based on the status information of the renderer context, thereby completing at least one page rendering operation of the currently running page of the target application instance.
[0065] In the data processing method proposed in the embodiment of the present disclosure, resource data can be directly accessed when calling a function function, and there is no need to write a program for passing the instance ID in the function function. This not only eliminates the need to frequently pass the ID during the switching and calling of the function function, thereby increasing the program response rate and reducing code redundancy, but also simplifies the difficulty of resource management of multiple application instances, reducing the pressure on developers.
[0066] In an embodiment of the present disclosure, using resource data for calculations in a program corresponding to a target thread can be achieved by calling a function. Here, the programming language of the called function may be the same as the programming language of the target thread, or may be different from the programming language of the target thread. The present disclosure does not impose any restrictions on this.
[0067] It should be noted that in the same programming language environment, the execution rate of calling function is better and the data transmission error rate is lower; in different programming language environments, the execution rate of calling function is slightly slower, and data transmission is prone to errors, affecting the running results of the application instance.
[0068] In some embodiments, the programming language of the called utility function is different from the programming language in which the target thread is running.
[0069] Here, the functions called across programming languages mainly include foreign function call (Foreign Function Interface, FFI) functions, which are functions written in a programming language different from the current target thread programming language to execute the program logic corresponding to the external function call function.
[0070] For example, the programming language corresponding to the current target thread is C++, and the function used by a certain operation process of running the application instance does not exist in the current programming environment, so a function written in C is called based on this. The process of calling the function here can be implemented by the following program:
[0071] extern "C" void ffiFunction() {
[0072] }
[0073] Here, ffiFunction is a function written in C.
[0074] For another example, the programming language corresponding to the current target thread is Java, and the function used by a certain operation process of running the application instance does not exist in the current programming environment, based on which a function written in another programming language such as C is called. The process of calling the function here can be implemented by the following program:
[0075] public void callFFI(){
[0076] }
[0077] Here, callFFI can be a function written in C.
[0078] In the disclosed embodiment, when the function function is called across programming languages, since the called function function in this solution can directly access the resource data bound to the target thread, there is no need to write code in the program to obtain the instance ID, and there is no need to obtain the resource data through the instance ID. Therefore, the data transmission steps are reduced, which not only speeds up the program response time, but also reduces the data transmission error rate, thereby improving the effectiveness of running the target application instance.
[0079] In some embodiments, the resource data of the target application instance includes target instance variables; in this case, see Figure 3 , Figure 3 A data processing method according to an exemplary embodiment is shown in FIG. Figure 3 ;like Figure 1 and Figure 3 As shown, the data processing method proposed in the present disclosure further comprises the following steps:
[0080] Step S103: Bind the target instance variable to the target thread based on the variable binding tool.
[0081] Here, the variable binding tool is a management tool based on the Thread Local Storage (TLS) technology. Based on the variable binding tool, multiple target instance variables corresponding to the running target application instance can be bound to the target thread when the target thread is responded to, forming private variables of the target thread; these target instance variables can be stored in the private storage space allocated to the target thread, or managed by the corresponding API. During the running of the target thread, the target thread can independently obtain, use, and update the data corresponding to these target instance variables, and will not affect the data in other parallel threads, nor will it be affected by the behavior in other threads.
[0082] In the embodiments of the present disclosure, the variable binding tools provided by different programming languages may be the same or different. When the electronic device to which the data processing method proposed in the present disclosure is applied runs in different operating system environments, the variable binding tools used may also be the same or different. The present disclosure does not impose any further restrictions on this.
[0083] Exemplarily, the electronic device to which the current data processing method is applied runs under the Windows operating system, and the application framework mentioned in the present disclosure is written based on the programming language C#. In this case, the variable binding tool mentioned in the present disclosure can be a management class; specifically, by creating the management class and using the API corresponding to the management class to manage the above target instance variables, the target thread can privately use the target instance variables based on this. The application program interface corresponding to the management class includes: allocation space function TlsAlloc, acquisition function TlsGetValue, assignment function TlsSetValue, etc.
[0084] The disclosed embodiment binds the resource data of the target application instance, such as the target instance variables, to the target thread through a variable binding tool. When calling a function, the target thread can directly use these instance variables without having to obtain the instance variables managed by the instance ID based on the instance ID, thereby reducing the steps of data transmission, improving the convenience of accessing resource data during the operation of the target thread, and further improving the execution speed and efficiency of starting the target application instance.
[0085] In some embodiments, instance variables include, but are not limited to: renderer context, event loop handle, application development execution engine, storage path of computer application code in the file system, meta information of the target application, etc.
[0086] Here, the rendering context is a data structure that stores rendering information. It saves various status information in the program context, including vertex information, texture information, compiled shader information, etc. The renderer context disclosed in the present invention can be used to render the startup interface of the target application instance; the event loop handle is a long-term object that can execute certain operations of starting the application instance during the life cycle of the opened thread, such as the loop of libuv; the application development execution engine includes an interpreter, a just-in-time compiler, and a garbage collector, which are used to interpret / compile bytecode instructions into machine instructions that can be recognized by electronic devices; the meta information of the target application includes the list information, configuration information, permission information, and the width and height of the application window designed by the application development designer of the target application.
[0087] The present disclosure can bind the above-mentioned multiple instance variables corresponding to the application instance to the target thread, so that multiple operation steps of starting and running the target application instance can be completed quickly and efficiently, thereby improving the program response rate and further enhancing the user experience.
[0088] In some embodiments, the variable binding tool includes a thread local storage keyword, and binding the target instance variable to the target thread based on the variable binding tool includes:
[0089] Based on the declaration of the target instance variable using the thread local storage keyword, the target instance variable is bound to the target thread.
[0090] Here, the thread local storage keywords mentioned in the present disclosure are based on the tools provided by the programming language C++; the thread local storage keywords include thread_local; in the actual running process, after declaring the target instance variable through thread_local, the target instance variable becomes the local variable of the thread and also a private variable. In this way, during the running of the target thread, the target thread can independently obtain, use, and update the data corresponding to these target instance variables, and will not affect the data in other parallel threads, nor will it be affected by the behavior in other threads.
[0091] In the present disclosure, declaring a target instance variable through thread_local can be implemented through the following procedure:
[0092] thread_local int myInstanceData;
[0093] Here, myInstanceData is an exemplary target instance variable.
[0094] The present disclosure can declare target instance variables based on local thread storage keywords, so that the data corresponding to these target instance variables can be independently obtained, used, and updated in the target thread to run the target application instance, reducing the need to frequently pass the instance ID when using the resource data of the target application instance in the target thread. In this way, the target application instance can be started and run quickly and efficiently, thereby improving the user experience.
[0095] In some embodiments, the variable binding tool includes a target class; binding the target instance variable to the target thread based on the variable binding tool includes:
[0096] Initialize the target class; the target class is used to manage variables in the target thread;
[0097] Based on the target class's declaration of the target instance variable, bind the target instance variable to the target thread.
[0098] Here, the target class mentioned in the present disclosure is a tool provided by the programming language Java; the target class includes ThreadLocal; here, the ThreadLocal class is a class for thread local storage, and the API corresponding to the class is used to manage the thread's local storage variables by creating the class; here, a thread's local storage variable is its private variable, and the thread can independently obtain, use, and update the data corresponding to the local storage variable, and will not affect the data in other parallel threads, nor will it be affected by the behavior in other threads; the API corresponding to the ThreadLocal class includes the acquisition function threadLocal.get, the assignment function threadLocal.set, and the removal function threadLocal.remove, etc.; threadLocal.get can obtain the value of the thread local storage variable during the thread running process; threadLocal.set can set the value of the thread local storage variable during the thread running process; threadLocal.remove can delete the thread local storage variable managed by the ThreadLocal class and its corresponding value. In the actual running process, that is, when the target thread is started, by initializing the ThreadLocal class and declaring the target instance variable based on the ThreadLocal class, the target instance variable becomes the local storage variable of the thread, that is, the private variable of the target thread.
[0099] In the present disclosure, initializing the ThreadLocal class and declaring the target instance variable based on the ThreadLocal class can be implemented by the following procedure:
[0100] public class MyInstance{
[0101] private static ThreadLocal <integer>myInstanceData=ThreadLocal.withInitial(()->0);
[0102] }
[0103] Here, ThreadLocal represents the target class, that is, the thread local storage class, and myInstanceData is an exemplary target instance variable.
[0104] The present disclosure can declare target instance variables based on the target class, so that the data corresponding to these target instance variables can be independently obtained, used, and updated in the target thread to run the target application instance, reducing the need to frequently pass the instance ID when using the resource data of the target application instance in the target thread. In this way, the target application instance can be started and run quickly and efficiently, thereby improving the user experience.
[0105] In some embodiments, the variable binding tool includes a target key; binding the target instance variable to the target thread based on the variable binding tool includes:
[0106] Initialize the target key; the target key is used to manage variables in the target thread;
[0107] Based on the key-value pair consisting of the target instance variable and the target key, the target instance variable is bound to the target thread.
[0108] The target key mentioned in the present disclosure is determined based on the thread specific data (TSD) technology and the tools provided by the programming language C; when determining the local storage variables that the thread needs to associate and manage, a target key instance_data_key can be created, and the thread local storage variables are bound to the target key to form a key-value pair, and these local storage variables are managed according to the API corresponding to the key-value pair; here, the API corresponding to the target key can be an acquisition function pthread_getspecific, a setting function pthread_setspecific, and a removal function pthread_key_delete, etc.; pthread_getspecific can obtain a thread local storage variable bound to instance_data_key during the thread running process; pthread_setspecific can form a key-value pair with a thread local storage variable and instance_data_key during the thread running process; pthread_key_delete can destroy a thread local storage variable bound to instance_data_key. In the actual running process, that is, when the target thread is started, the instance_data_key is initialized, and a key-value pair is formed based on the instance_data_key and the target instance variable. The target instance variable becomes the local storage variable of the target thread, that is, the private variable of the target thread.
[0109] In this disclosure, initializing instance_data_key can be achieved by the following procedure:
[0110] pthread_key_create(&instance_data_key, NULL);
[0111] Composing key-value pairs based on target keys and target instance variables can be achieved through the following procedures:
[0112] pthread_setspecific(instance_data_key, data);
[0113] Here, data is an exemplary target instance variable.
[0114] The present disclosure can form a key-value pair with the target instance variable and the created target key when the target thread is started, so that the target instance variables stored in the key-value pair can be independently obtained, used, and updated in the target thread to run the target application instance, reducing the need to frequently pass the instance ID when using the resource data of the target application instance in the target thread. In this way, the target application instance can be started and run quickly and efficiently, thereby improving the user experience.
[0115] When the data processing method proposed in the present disclosure is applied in different operating systems, the variable binding tools used may be the same or different. In some examples, when the data processing method proposed in the present disclosure is applied in a Unix-like operating system environment, the variable binding tool may be the above-mentioned target key. For another example, when the data processing method proposed in the present disclosure is applied on a Mac operating system, the variable binding tool may be the above-mentioned target key, or it may be a target pointer determined based on the Grand Central Dispatch (GCD) technology and applied based on the programming language C; the target pointer may be a pointer of the dispatch_queue_t type assigned by the target thread, and the target application instance is bound to the target thread through the target pointer; for another example, when the data processing method proposed in the present disclosure is applied on a Windows operating system, the variable binding tool may be the above-mentioned target key, target class, and thread local storage keyword, etc., and the present disclosure does not make further restrictions on this.
[0116] The present disclosure also provides a data processing device. Figure 4 , Figure 4 is a structural diagram of a data processing device according to an exemplary embodiment; Figure 4 As shown, the data processing device 400 proposed in the present disclosure includes:
[0117] The thread creation module 401 is configured to create a target thread for running the target application instance based on a single-threaded application framework in response to a start event for the target application instance; wherein the target application instance is an instance for opening a target application program to run;
[0118] The running module 402 is configured to run the target application instance based on the resource data of the target application instance bound to the target thread during the running of the target thread.
[0119] In some embodiments, the running module 402 is also configured to obtain at least one of the resource data for executing the function function from the multiple resource data of the target application instance bound to the target thread during the process of calling the function function; and run the target application instance based on the function function and at least one of the resource data for executing the function function.
[0120] In some embodiments, the programming language of the called function is different from the programming language of the target thread.
[0121] In some embodiments, the resource data of the target application instance includes target instance variables, and the data processing device 400 further includes:
[0122] Binding Module( Figure 4 ), and is configured to bind the target instance variable to the target thread based on a variable binding tool.
[0123] In some embodiments, the variable binding tool includes a thread local storage keyword, and the binding module is further configured to call the thread local storage keyword; based on the declaration of the target instance variable by the thread local storage keyword, bind the target instance variable to the target thread.
[0124] In some embodiments, the variable binding tool includes a target class; the binding module is also configured to initialize the target class; the target class is used to manage variables in the target thread; based on the declaration of the target instance variable by the target class, the target instance variable is bound to the target thread.
[0125] In some embodiments, the variable binding tool includes a target key; the binding module is also configured to initialize the target key; the target key is used to manage variables in the target thread; based on a key-value pair consisting of the target instance variable and the target key, the target instance variable is bound to the target thread.
[0126] In some embodiments, the instance variables include but are not limited to: a renderer context, an event loop handle, an application development execution engine, a storage path of computer application code in a file system, and meta information of the target application.
[0127] The present disclosure also provides an electronic device, characterized in that it includes:
[0128] processor;
[0129] a memory for storing processor-executable instructions;
[0130] Among them, the processor is configured to execute the data processing method proposed in the above embodiments of the present disclosure.
[0131] Figure 5 is a block diagram of an electronic device according to an exemplary embodiment. Figure 5 , the electronic device 500 includes a processing component 522, which further includes one or more processors, and a memory resource represented by a memory 532 for storing instructions that can be executed by the processing component 522, such as an application. The application stored in the memory 532 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 522 is configured to execute instructions to perform the above-mentioned information processing method.
[0132] The electronic device 500 may also include a power supply component 526 configured to perform power management of the electronic device 500, a wired or wireless network interface 550 configured to connect the electronic device 500 to a network, and an input / output (I / O) interface 558. The electronic device 500 may operate based on an operating system stored in the memory 532, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™ or the like.
[0133] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 532 including instructions, and the instructions can be executed by the processing component 522 of the electronic device 500 to complete the above data processing method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0134] A non-transitory computer-readable storage medium, when instructions in the storage medium are executed by a processing component of an electronic device, enables the electronic device to perform a data processing method, the data processing method comprising:
[0135] In response to a start event for a target application instance, a target thread for running the target application instance is created based on a single-threaded application framework; wherein the target application instance is an instance for opening a target application program for running;
[0136] In the process of running the target thread, the target application instance is run based on the resource data of the target application instance bound to the target thread.
[0137] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0138] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.< / integer>
Claims
1. A data processing method, characterized in that: The method comprises: In response to a start event for a target application instance, a target thread for running the target application instance is created based on a single-threaded application framework; wherein the target application instance is an instance for opening a target application program for running; In the process of running the target thread, the target application instance is run based on the resource data of the target application instance bound to the target thread.
2. The data processing method according to claim 1, characterized in that: The running the target application instance based on the resource data of the target application instance bound to the target thread includes: In the process of calling the function function, acquiring at least one resource data for executing the function function from the plurality of resource data of the target application instance bound to the target thread; The target application instance is run based on the functional function and at least one resource data for executing the functional function.
3. The data processing method according to claim 2, characterized in that: The programming language of the called function is different from the programming language of the target thread.
4. The data processing method according to any one of claims 1 to 3, characterized in that: The resource data of the target application instance includes target instance variables, and the method further includes: The target instance variable is bound to the target thread based on a variable binding tool.
5. The data processing method according to claim 4, characterized in that: The variable binding tool includes a thread local storage keyword, and the step of binding a target instance variable to the target thread based on the variable binding tool includes: Based on the declaration of the target instance variable by the thread local storage keyword, the target instance variable is bound to the target thread.
6. The data processing method according to claim 4, characterized in that: The variable binding tool includes a target class; The step of binding the target instance variable to the target thread based on the variable binding tool includes: Initialize the target class; the target class is used to manage variables in the target thread; Based on the declaration of the target instance variable by the target class, the target instance variable is bound to the target thread.
7. The data processing method according to claim 4, characterized in that: The variable binding tool includes a target key; The step of binding the target instance variable to the target thread based on the variable binding tool includes: Initializing the target key; the target key is used to manage variables in the target thread; The target instance variable is bound to the target thread based on a key-value pair consisting of the target instance variable and the target key.
8. The data processing method according to claim 4, characterized in that: The target instance variables include, but are not limited to: a renderer context, an event loop handle, an application development execution engine, a storage path of computer application codes in a file system, and meta information of the target application.
9. A data processing device, characterized in that: include: A thread creation module is configured to create a target thread for running the target application instance based on a single-threaded application framework in response to a start event for the target application instance; wherein the target application instance is an instance for opening a target application program for running; The running module is configured to run the target application instance based on the resource data of the target application instance bound to the target thread during the running of the target thread.
10. The data processing device according to claim 9, characterized in that: The resource data of the target application instance includes target instance variables, and the device further includes: The binding module is configured to bind the target instance variable to the target thread based on a variable binding tool.
11. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to execute the data processing method according to any one of claims 1 to 8.
12. A non-transitory computer-readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the data processing method as claimed in any one of claims 1 to 8.
Citation Information
Patent Citations
Un-synchronized pool for software components
US20070169122A1