CN113138883A - Message processing method and device, storage medium and electronic equipment - Google Patents
Message processing method and device, storage medium and electronic equipment Download PDFInfo
- Publication number
- CN113138883A CN113138883A CN202110530206.5A CN202110530206A CN113138883A CN 113138883 A CN113138883 A CN 113138883A CN 202110530206 A CN202110530206 A CN 202110530206A CN 113138883 A CN113138883 A CN 113138883A
- Authority
- CN
- China
- Prior art keywords
- message
- daemon
- main thread
- processing
- target
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000003672 processing method Methods 0.000 title abstract description 18
- 238000012544 monitoring process Methods 0.000 claims abstract description 40
- 238000012545 processing Methods 0.000 claims description 82
- 238000000034 method Methods 0.000 claims description 51
- 230000008569 process Effects 0.000 claims description 22
- 238000004590 computer program Methods 0.000 claims description 19
- 230000004044 response Effects 0.000 abstract description 5
- 238000010586 diagram Methods 0.000 description 9
- 230000006870 function Effects 0.000 description 8
- 238000004891 communication Methods 0.000 description 7
- 230000003287 optical effect Effects 0.000 description 6
- 239000013307 optical fiber Substances 0.000 description 2
- 230000000644 propagated effect Effects 0.000 description 2
- 239000004065 semiconductor Substances 0.000 description 2
- 238000013459 approach Methods 0.000 description 1
- 238000003491 array Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000007935 neutral effect Effects 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/14—Error detection or correction of the data by redundancy in operation
- G06F11/1402—Saving, restoring, recovering or retrying
- G06F11/1415—Saving, restoring, recovering or retrying at system level
- G06F11/1438—Restarting or rejuvenating
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Transfer Between Computers (AREA)
Abstract
The disclosure relates to a message processing method, a device, a storage medium and an electronic device, which determine whether a guarded message exists in a message queue of a main thread, wherein the guarded message is a message with high priority; for each determined daemon message, judging whether the daemon message is not processed at the monitoring time corresponding to the daemon message, and taking the daemon message as a target daemon message under the condition that the daemon message is determined not processed, wherein the monitoring time corresponding to the daemon message is earlier than or equal to the latest execution time corresponding to the daemon message; when the main thread runs to the anchor point, the target guarded message is processed at the anchor point, and the target guarded message is processed by the anchor point in time, so that the response performance of the target guarded message is improved.
Description
Technical Field
The present disclosure relates to the field of message processing, and in particular, to a message processing method, device, storage medium, and electronic device.
Background
In the actual development process of the application, different messages have different requirements on the execution timing, and in some specific messages, for example, messages related to service components, broadcast components, and input types are Not executed timely, so that the application does Not respond, and anr (application Not responding) occurs. The ANR is a dialog box that is displayed to a user by the android system when the response of an application program is not sensitive enough on the android system, and the user may select "wait" to allow the application program to continue running or "force close". ANR cannot be present in a fluent application to avoid having the user process the dialog many times.
Therefore, the design of the response performance for messages with high priority on execution timing, such as messages that easily cause ANR, in an application is particularly important.
Disclosure of Invention
This summary is provided to introduce a selection of concepts in a simplified form that are further described below in the detailed description. This summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used to limit the scope of the claimed subject matter.
In a first aspect, the present disclosure provides a message processing method, including:
determining a guarded message in a main thread message queue, wherein the guarded message is a message with high priority to execution opportunity;
for each determined daemon message, judging whether the daemon message is not processed at the monitoring time corresponding to the daemon message, and taking the daemon message as a target daemon message under the condition that the daemon message is determined not to be processed, wherein the monitoring time corresponding to the daemon message is earlier than or equal to the latest execution time corresponding to the daemon message;
and when the main thread runs to an anchor point, processing the target protected message at the anchor point, wherein the main thread is provided with a plurality of anchor points.
In a second aspect, the present disclosure provides a message processing apparatus, the apparatus comprising:
the system comprises a determining module, a judging module and a judging module, wherein the determining module is used for determining a guarded message in a main thread message queue, and the guarded message is a message with high priority;
a judging module, configured to judge, for each determined daemon message, at a monitoring time corresponding to the daemon message, whether the daemon message is unprocessed, and when it is determined that the daemon message is unprocessed, take the daemon message as a target daemon message, where the monitoring time corresponding to the daemon message is earlier than or equal to a latest execution time corresponding to the daemon message;
and the processing module is used for processing the target protected message at the anchor point when the main thread runs to the anchor point, wherein the main thread is provided with a plurality of anchor points.
In a third aspect, the present disclosure provides a computer-readable medium, on which a computer program is stored, which program, when executed by a processing device, implements the steps of the message processing method of any of the first aspects described above.
In a fourth aspect, the present disclosure provides an electronic device comprising:
a storage device having a computer program stored thereon;
processing means for executing the computer program in the storage means to implement the steps of the message processing method according to any one of the first aspect above.
Through the technical scheme, the messages (the guarded messages) determined to have high priority in the message queue of the main thread are monitored, the guarded messages are used as the target guarded messages when the condition that the guarded messages are not processed at the monitoring time corresponding to the guarded messages is determined, the target guarded messages are processed at the anchor points when the main thread runs to the anchor points, and due to the fact that a plurality of anchor points are arranged on the main thread, the target guarded messages can be processed by the anchor points in time, and response performance of the guarded messages is improved.
Additional features and advantages of the disclosure will be set forth in the detailed description which follows.
Drawings
The above and other features, advantages and aspects of various embodiments of the present disclosure will become more apparent by referring to the following detailed description when taken in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numbers refer to the same or similar elements. It should be understood that the drawings are schematic and that elements and features are not necessarily drawn to scale. In the drawings:
fig. 1 is a flowchart illustrating a message processing method according to an exemplary embodiment of the present disclosure.
Fig. 2 is a logic diagram illustrating a message processing method according to an exemplary embodiment of the present disclosure.
Fig. 3 is a block diagram illustrating a message processing apparatus according to an exemplary embodiment of the present disclosure.
Fig. 4 is a block diagram illustrating an electronic device according to an exemplary embodiment of the present disclosure.
Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order, and/or performed in parallel. Moreover, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "include" and variations thereof as used herein are open-ended, i.e., "including but not limited to". The term "based on" is "based, at least in part, on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions for other terms will be given in the following description.
It should be noted that the terms "first", "second", and the like in the present disclosure are only used for distinguishing different devices, modules or units, and are not used for limiting the order or interdependence relationship of the functions performed by the devices, modules or units.
It is noted that references to "a", "an", and "the" modifications in this disclosure are intended to be illustrative rather than limiting, and that those skilled in the art will recognize that "one or more" may be used unless the context clearly dictates otherwise.
The names of messages or information exchanged between devices in the embodiments of the present disclosure are for illustrative purposes only, and are not intended to limit the scope of the messages or information.
As is known in the art, the response performance of the related art to a message having a high priority is particularly important in the process of processing the message by the main thread. In view of this, the embodiments of the present disclosure provide a message processing method, an apparatus, a storage medium, and an electronic device, which can ensure that a daemon message determined in a message queue of a main thread can be processed in time.
Fig. 1 is a flowchart illustrating a message processing method according to an exemplary embodiment of the present disclosure. Referring to fig. 1, the message processing method may include:
It should be noted that the daemon message is a message having a high priority. A message with a high priority is a message that needs to be responded to in time more than a message with a low priority.
For example, a daemon message may be a message in a message queue of a main thread that is determined to cause ANR, where the message in the message queue would cause ANR if the message was not processed yet at a corresponding latest execution time. It should be noted that the message that will cause ANR if the corresponding latest execution time has not yet been processed may be, for example, a message related to a Service component or a Receiver component in an android application, and may also be, for example, a message related to an input type.
The embodiments of the present disclosure will be further explained below with the guarded message being the message that will cause ANR.
Illustratively, the monitoring time corresponding to the daemon message is earlier than or equal to the latest execution time corresponding to the daemon message. Considering that a certain processing time is required for judging whether the guarded message is processed, the monitoring time can be set to be earlier than the latest execution time corresponding to the guarded message, and whether the guarded message is processed can be judged at the earlier time than the latest execution time corresponding to the guarded message, so that the probability of ANR caused by the fact that the guarded message is not processed at the latest is effectively reduced.
For example, the monitoring time may be a time corresponding to a preset time length before the latest execution time corresponding to the daemon message. The preset duration can be set according to actual conditions, and the implementation does not limit the preset duration.
In the present disclosure, a plurality of anchor points are provided on the main thread. For example, the execution time of the anchor point may be set as a switching neutral time at which two messages are processed.
It should be noted that the above method steps may be performed when the main thread is started.
By the above manner, a message (guarded message) determined to cause ANR in the message queue of the main thread is monitored, when the guarded message is determined to be not processed at the monitoring time corresponding to the guarded message, the guarded message is used as a target guarded message, and when the main thread runs to an anchor point, the target guarded message is processed at the anchor point.
In order to make the message processing method provided by the present disclosure more understood, the following detailed description is given for each step.
In a possible implementation, the daemon message comprises a message of a service type, a broadcast type and/or an input type.
In a possible embodiment, the daemon message may be determined in the following manner.
Specifically, first, the message type of each message in the message queue is acquired.
It should be understood that each message carries a field for representing the type of the message, and the message type of the message can be obtained by obtaining and analyzing the field.
Then, the message with the message type of service type, broadcast type and/or input type in the message queue is determined as the message which will cause ANR, so as to obtain the guarded message.
Illustratively, the Service type may be, for example, a message related to a Service component in an android application; the broadcast type may be, for example, a message in an android application related to a Receiver component.
In android application usage, each text box corresponds to a particular type of text entry, such as Email address, phone number, or plain text. It is important to specify the type of input for each textbox in the application, which may allow the system to display more appropriate soft input methods (e.g., virtual keyboards), which may be used as ANR-causing messages because of the higher timeliness required for display of the input methods, i.e., the higher timeliness required for handling messages that allow the system to display which input method.
In a possible approach, the main thread adds an anchor point within each message in the message queue as it processes that message. In this case, step 103 shown in FIG. 1 may include processing the target guarded message at an anchor point within the currently processed message as the main thread runs the anchor point.
In this embodiment, when the main thread processes each message in the message queue, an anchor point is added to the message, and when the main thread runs the anchor point inside the currently processed message, it is equivalent to that the target guarded message can be directly placed inside the message pointed by the anchor point to be executed.
In a possible embodiment, in the step 102 shown in fig. 1, in the case that it is determined that the daemon message is not processed, taking the daemon message as the target daemon message may specifically include: in the event that it is determined that the daemon message is not processed, the daemon message is added to an urgent queue. The emergency queue is used for storing target guarded messages. In this case, step 103 shown in fig. 1 may include: and when the main thread runs to each anchor point, sequentially taking out the target guarded message from the emergency queue for processing.
It should be noted that messages in the urgent queue are processed by the main thread preferentially over messages in the main thread's message queue.
In this way, in the process that the last determined target daemon message is processed by the currently executed anchor point, a plurality of target daemon messages are determined, in this case, in order to ensure that each target daemon message determined in the process is sequentially processed by the anchor point preferentially, an emergency queue may be provided for storing the determined target daemon messages, since messages in the emergency queue are preferentially processed compared with messages in the message queue of the main thread, when the process is executed, the anchor point preferentially processes the target daemon messages stored in the emergency queue until no target daemon message exists in the emergency queue and needs to be processed.
In a possible implementation, step 102 shown in fig. 1 may include: for each determined daemon message, judging whether the daemon message exists in a message queue of the main thread at the monitoring time corresponding to the daemon message; in a case where it is determined that the daemon message exists in the message queue of the main thread, it is determined that the daemon message is not processed, and the daemon message is taken as a target daemon message.
Fig. 2 is a logic diagram illustrating a message processing method according to an exemplary embodiment of the present disclosure. Illustratively, the determined daemon messages comprise a message A, a message C and a message F, the messages existing in the current message queue of the main thread comprise a message B, a message C, a message E, a message F and a message G, and at the monitoring time of the message A, the message A is determined to be processed or is being processed because the message A does not exist in the message queue of the main thread, and the daemon is not needed.
Still taking fig. 2 as an example, at the monitoring time of the message C, since the message C exists in the message queue of the main thread, it is determined that the message C is not processed, and it needs to be guarded, that is, the message C needs to be targeted to be guarded, and when the main thread runs to an anchor point, the message C is processed at the anchor point.
In this embodiment, in consideration of the feature that the message queue disappears from the message queue after the message is taken out (processed), whether the daemon message exists in the message queue of the main thread can be determined by using the feature, so as to determine whether the daemon message is processed.
In a possible implementation, the message processing method further includes: creating a daemon thread; after each determined daemon message, a daemon message associated with the daemon message is created and the processing time of the daemon message is set.
The processing time of the daemon message is equal to the monitoring time corresponding to the daemon message related to the daemon message.
In this embodiment, the daemon thread is another thread different from the main thread, and the daemon thread is configured to process each daemon message at a processing time of the daemon message, so as to determine whether a daemon message associated with the daemon message is unprocessed, and in a case that it is determined that the daemon message is unprocessed, take the daemon message as a target daemon message.
In a possible embodiment, the daemon thread is also used to: traversing all messages in the message queue of the main thread to obtain the information characteristics of all messages in the message queue of the main thread; and determining the message corresponding to the information characteristic as the guarded message under the condition that any acquired information characteristic comprises the preset information characteristic.
It should be understood that each message has some information characteristic that is distinct from other classes of messages. Therefore, whether all messages in the message queue are the guarded messages or not can be judged according to the information characteristics and the preset information characteristics of all messages in the message queue.
It should be noted that the preset information characteristics of the service type and broadcast type input type messages are different.
Still further explaining the present embodiment with fig. 2, the message C, the message F, and the message a are messages determined to cause ANR in the message queue of the main thread, that is, guarded messages. The messages in the message queue of the main thread comprise a message B, a message C, a message E, a message F and a message G, and the sequence of the sequential execution of the messages in the message queue of the main thread is as follows: message B → message C → message E → message F → message G, and the direction of the arrow on the main thread indicates the direction in which each anchor moves, and also characterizes the order in which each anchor executes in sequence. The message currently being processed is message B, anchor 1 is established inside message B, anchor 2 is established between message B and message C of the main thread, and similarly to anchor 1 and anchor 2, anchor 3, anchor 4, anchor 5, anchor 6, and anchor 7.
In fig. 2, when the message C processes the daemon message associated with the message C at its monitoring time, that is, the daemon thread processes the daemon message associated with the message C at a processing time (equal to the monitoring time), it is found that the message C is also stored in the message queue of the main thread at the processing time, that is, has not been processed. Thus, message C is determined to be the targeted daemon message. In this case, since the anchor point 1 is provided inside the message B, when the anchor point 1 runs, the message C may be processed at the anchor point 1, so as to avoid that the message C causes ANR due to untimely processing.
If no anchor is established within message B in fig. 2, message C may be processed at anchor point 2 when running to anchor point 2.
Based on the same inventive concept, the embodiment of the present disclosure also provides a message processing apparatus, which may become part or all of an electronic device through software, hardware, or a combination of both. Referring to fig. 3, the message processing apparatus 300 includes:
a determining module 301, configured to determine a daemon message in the main thread message queue, where the daemon message is a message with a high priority for an execution opportunity.
A determining module 302, configured to determine, for each determined daemon message, at a monitoring time corresponding to the daemon message, whether the daemon message is unprocessed, and if it is determined that the daemon message is unprocessed, take the daemon message as a target daemon message, where the monitoring time corresponding to the daemon message is earlier than or equal to a latest execution time corresponding to the daemon message.
A processing module 303, configured to process the target protected message at an anchor point when the main thread runs to the anchor point, where the main thread is provided with multiple anchor points.
Optionally, the daemon message includes: a service type, a broadcast type, and/or an input type.
Optionally, the message processing apparatus 300 further includes:
and the adding module is used for adding an anchor point in each message when the main thread processes the message in the message queue.
The processing module 303 is configured to:
and when the main thread runs the anchor point in the currently processed message, processing the target protected message at the anchor point.
Optionally, the determining module 301 is configured to:
in the event that it is determined that the daemon message is not processed, adding the daemon message to an urgent queue for storing the target daemon message.
The processing module 303 is configured to:
and when the main thread runs to each anchor point, sequentially taking out the target daemon information from the emergency queue for processing.
Optionally, the determining module 302 is configured to:
for each determined daemon message, judging whether the daemon message exists in a message queue of the main thread at the monitoring time corresponding to the daemon message;
determining that the daemon message is not processed under the condition that the daemon message exists in the message queue of the main thread; and the number of the first and second electrodes,
the daemon message is used as a target daemon message.
Optionally, the message processing apparatus 300 further includes:
the first establishing module is used for establishing a daemon thread.
A second creating module, configured to create, after each determined daemon message is received, a daemon message associated with the daemon message and set a processing time of the daemon message, where the daemon message is used for the daemon thread to process, and the processing time is a monitoring time corresponding to the daemon message associated with the daemon message;
the daemon thread is used for processing the daemon message at the processing time of each daemon message so as to judge whether the daemon message associated with the daemon message is unprocessed or not, and the daemon thread takes the daemon message as a target daemon message under the condition that the daemon message is determined to be unprocessed.
Optionally, the daemon thread is further configured to:
traversing all messages in the message queue of the main thread to acquire the information characteristics of all messages in the message queue of the main thread; and the number of the first and second electrodes,
and under the condition that any acquired information characteristic comprises a preset information characteristic, determining a message corresponding to the information characteristic as the daemon message.
Based on the same inventive concept, the disclosed embodiments also provide a computer readable medium, on which a computer program is stored, which when executed by a processing device, implements the steps of any of the above-described message processing methods.
Based on the same inventive concept, an embodiment of the present disclosure further provides an electronic device, including:
a storage device having a computer program stored thereon;
processing means for executing the computer program in the storage means to implement the steps of any of the message processing methods described above.
Referring now to FIG. 4, a block diagram of an electronic device 400 suitable for use in implementing embodiments of the present disclosure is shown. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a stationary terminal such as a digital TV, a desktop computer, and the like. The electronic device shown in fig. 4 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 4, electronic device 400 may include a processing device (e.g., central processing unit, graphics processor, etc.) 401 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)402 or a program loaded from a storage device 408 into a Random Access Memory (RAM) 403. In the RAM 403, various programs and data necessary for the operation of the electronic apparatus 400 are also stored. The processing device 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input/output (I/O) interface 405 is also connected to bus 404.
Generally, the following devices may be connected to the I/O interface 405: input devices 406 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 407 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 408 including, for example, tape, hard disk, etc.; and a communication device 409. The communication means 409 may allow the electronic device 400 to communicate wirelessly or by wire with other devices to exchange data. While fig. 4 illustrates an electronic device 400 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer readable medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication device 409, or from the storage device 408, or from the ROM 402. The computer program performs the above-described functions defined in the methods of the embodiments of the present disclosure when executed by the processing device 401.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
In some embodiments, the communication may be performed using any currently known or future developed network Protocol, such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the Internet (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed network.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: determining a guarded message in a main thread message queue, wherein the guarded message is a message with high priority to execution opportunity; for each determined daemon message, judging whether the daemon message is not processed at the monitoring time corresponding to the daemon message, and taking the daemon message as a target daemon message under the condition that the daemon message is determined not to be processed, wherein the monitoring time corresponding to the daemon message is earlier than or equal to the latest execution time corresponding to the daemon message; and when the main thread runs to an anchor point, processing the target protected message at the anchor point, wherein the main thread is provided with a plurality of anchor points.
Computer program code for carrying out operations for the present disclosure may be written in any combination of one or more programming languages, including but not limited to an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present disclosure may be implemented by software or hardware. Wherein the name of a module in some cases does not constitute a limitation on the module itself.
The functions described herein above may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), systems on a chip (SOCs), Complex Programmable Logic Devices (CPLDs), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
Example 1 provides a message processing method according to one or more embodiments of the present disclosure, including:
determining a daemon message in a main thread message queue, wherein the daemon message has a message with high priority on execution opportunity;
for each determined daemon message, judging whether the daemon message is not processed at the monitoring time corresponding to the daemon message, and taking the daemon message as a target daemon message under the condition that the daemon message is determined not to be processed, wherein the monitoring time corresponding to the daemon message is earlier than or equal to the latest execution time corresponding to the daemon message;
and when the main thread runs to an anchor point, processing the target protected message at the anchor point, wherein the main thread is provided with a plurality of anchor points.
Example 2 provides the method of example 1, the daemon message comprising: a service type, a broadcast type, and/or an input type.
Example 3 provides the method of example 1, the main thread adding an anchor within each message in the message queue as it is processed;
when the main thread runs to an anchor point, processing the target protected message at the anchor point, wherein the processing comprises:
and when the main thread runs the anchor point in the currently processed message, processing the target protected message at the anchor point.
Example 4 provides the method of example 1, wherein taking the daemon message as the target daemon message if it is determined that the daemon message is not processed, comprising:
in the event that the daemon message is determined not to be processed, adding the daemon message to an urgent queue, wherein the urgent queue is used for storing a target daemon message;
when the main thread runs to an anchor point, processing the target protected message at the anchor point, wherein the processing comprises:
and when the main thread runs to each anchor point, sequentially taking out the target daemon information from the emergency queue for processing.
According to one or more embodiments of the present disclosure, example 5 provides the method of example 1, where, for each determined daemon message, at a monitoring time corresponding to the daemon message, determining whether the daemon message is unprocessed, and in a case that it is determined that the daemon message is unprocessed, regarding the daemon message as a target daemon message, the method includes:
for each determined daemon message, judging whether the daemon message exists in a message queue of the main thread at the monitoring time corresponding to the daemon message;
determining that the daemon message is not processed under the condition that the daemon message exists in the message queue of the main thread; and the number of the first and second electrodes,
the daemon message is used as a target daemon message.
Example 6 provides the method of any one of examples 1-5, further comprising, in accordance with one or more embodiments of the present disclosure:
creating a daemon thread;
after each determined daemon message is received, creating a daemon message associated with the daemon message and setting processing time of the daemon message, wherein the daemon message is used for the daemon thread to process, and the processing time is monitoring time corresponding to the daemon message associated with the daemon message;
the daemon thread is used for processing the daemon message at the processing time of each daemon message so as to judge whether the daemon message associated with the daemon message is unprocessed or not, and the daemon thread takes the daemon message as a target daemon message under the condition that the daemon message is determined to be unprocessed.
Example 7 provides the method of example 6, the daemon thread is further to:
traversing all messages in the message queue of the main thread to acquire the information characteristics of all messages in the message queue of the main thread; and the number of the first and second electrodes,
and under the condition that any acquired information characteristic comprises a preset information characteristic, determining a message corresponding to the information characteristic as the daemon message.
Example 8 provides, in accordance with one or more embodiments of the present disclosure, a message processing apparatus, the apparatus comprising:
the determining module is used for determining a guarded message in the main thread message queue, wherein the guarded message is a message with high priority to the execution opportunity.
And the judging module is used for judging whether the daemon message is unprocessed at the monitoring time corresponding to the daemon message for each determined daemon message, and taking the daemon message as a target daemon message under the condition that the daemon message is determined to be unprocessed, wherein the monitoring time corresponding to the daemon message is earlier than or equal to the latest execution time corresponding to the daemon message.
And the processing module is used for processing the target protected message at the anchor point when the main thread runs to the anchor point, wherein the main thread is provided with a plurality of anchor points.
Example 9 provides the apparatus of example 8, the daemon message comprising: a service type, a broadcast type, and/or an input type.
Example 10 provides the apparatus of example 8, the message processing apparatus further comprising, in accordance with one or more embodiments of the present disclosure:
and the adding module is used for adding an anchor point in each message when the main thread processes the message in the message queue.
The processing module is used for:
and when the main thread runs the anchor point in the currently processed message, processing the target protected message at the anchor point.
Example 11 provides the apparatus of example 8, the determination module to:
in the event that it is determined that the daemon message is not processed, adding the daemon message to an urgent queue for storing the target daemon message.
The processing module is used for:
and when the main thread runs to each anchor point, sequentially taking out the target daemon information from the emergency queue for processing.
Example 12 provides the apparatus of example 8, the determination module to:
for each determined daemon message, judging whether the daemon message exists in a message queue of the main thread at the monitoring time corresponding to the daemon message;
determining that the daemon message is not processed under the condition that the daemon message exists in the message queue of the main thread; and the number of the first and second electrodes,
the daemon message is used as a target daemon message.
Example 13 provides the apparatus of any one of examples 8-12, the message processing apparatus further comprising, in accordance with one or more embodiments of the present disclosure:
the first establishing module is used for establishing a daemon thread.
A second creating module, configured to create, after each determined daemon message is received, a daemon message associated with the daemon message and set a processing time of the daemon message, where the daemon message is used for the daemon thread to process, and the processing time is a monitoring time corresponding to the daemon message associated with the daemon message;
the daemon thread is used for processing the daemon message at the processing time of each daemon message so as to judge whether the daemon message associated with the daemon message is unprocessed or not, and the daemon thread takes the daemon message as a target daemon message under the condition that the daemon message is determined to be unprocessed.
Example 14 provides the apparatus of example 13, the daemon thread further to:
traversing all messages in the message queue of the main thread to acquire the information characteristics of all messages in the message queue of the main thread; and the number of the first and second electrodes,
and under the condition that any acquired information characteristic comprises a preset information characteristic, determining a message corresponding to the information characteristic as the daemon message.
Example 15 provides a computer readable medium having stored thereon a computer program that, when executed by a processing apparatus, performs the steps of the method of any one of examples 1 to 7, in accordance with one or more embodiments of the present disclosure.
Example 16 provides, in accordance with one or more embodiments of the present disclosure, an electronic device, comprising:
a storage device having a computer program stored thereon;
processing means for executing the computer program in the storage means to carry out the steps of the method of any one of examples 1 to 7.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents does not depart from the spirit of the disclosure. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.
Further, while operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limitations on the scope of the disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims. With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Claims (10)
1. A method of message processing, the method comprising:
determining a guarded message in a main thread message queue, wherein the guarded message is a message with high priority to execution opportunity;
for each determined daemon message, judging whether the daemon message is not processed at the monitoring time corresponding to the daemon message, and taking the daemon message as a target daemon message under the condition that the daemon message is determined not to be processed, wherein the monitoring time corresponding to the daemon message is earlier than or equal to the latest execution time corresponding to the daemon message;
and when the main thread runs to an anchor point, processing the target protected message at the anchor point, wherein the main thread is provided with a plurality of anchor points.
2. The method of claim 1, wherein the daemon message comprises: a service type, a broadcast type, and/or an input type.
3. The method of claim 1, wherein the main thread adds an anchor point within each message in the message queue as it processes the message;
when the main thread runs to an anchor point, processing the target protected message at the anchor point, wherein the processing comprises:
and when the main thread runs the anchor point in the currently processed message, processing the target protected message at the anchor point.
4. The method according to claim 1, wherein said regarding the daemon message as the target daemon message in case that the daemon message is determined not to be processed comprises:
in the event that the daemon message is determined not to be processed, adding the daemon message to an urgent queue, wherein the urgent queue is used for storing a target daemon message;
when the main thread runs to an anchor point, processing the target protected message at the anchor point, wherein the processing comprises:
and when the main thread runs to each anchor point, sequentially taking out the target daemon information from the emergency queue for processing.
5. The method according to claim 1, wherein the determining, for each determined daemon message, whether the daemon message is unprocessed at the monitoring time corresponding to the daemon message, and taking the daemon message as the target daemon message if the daemon message is determined to be unprocessed comprises:
for each determined daemon message, judging whether the daemon message exists in a message queue of the main thread at the monitoring time corresponding to the daemon message;
determining that the daemon message is not processed under the condition that the daemon message exists in the message queue of the main thread; and the number of the first and second electrodes,
the daemon message is used as a target daemon message.
6. The method according to any one of claims 1-5, further comprising:
creating a daemon thread;
after each determined daemon message is received, creating a daemon message associated with the daemon message and setting processing time of the daemon message, wherein the daemon message is used for the daemon thread to process, and the processing time is monitoring time corresponding to the daemon message associated with the daemon message;
the daemon thread is used for processing the daemon message at the processing time of each daemon message so as to judge whether the daemon message associated with the daemon message is unprocessed or not, and the daemon thread takes the daemon message as a target daemon message under the condition that the daemon message is determined to be unprocessed.
7. The method of claim 6, wherein the daemon thread is further configured to:
traversing all messages in the message queue of the main thread to acquire the information characteristics of all messages in the message queue of the main thread; and the number of the first and second electrodes,
and under the condition that any acquired information characteristic comprises a preset information characteristic, determining a message corresponding to the information characteristic as the daemon message.
8. A message processing apparatus, characterized in that the apparatus comprises:
the device comprises a determining module, a judging module and a judging module, wherein the determining module is used for determining a guarded message in a main thread message queue, and the guarded message is a message with high priority on execution opportunity;
a judging module, configured to judge, for each determined daemon message, at a monitoring time corresponding to the daemon message, whether the daemon message is unprocessed, and when it is determined that the daemon message is unprocessed, take the daemon message as a target daemon message, where the monitoring time corresponding to the daemon message is earlier than or equal to a latest execution time corresponding to the daemon message;
and the processing module is used for processing the target protected message at the anchor point when the main thread runs to the anchor point, wherein the main thread is provided with a plurality of anchor points.
9. A computer-readable medium, on which a computer program is stored, characterized in that the program, when being executed by processing means, carries out the steps of the method of any one of claims 1 to 7.
10. An electronic device, comprising:
a storage device having a computer program stored thereon;
processing means for executing the computer program in the storage means to carry out the steps of the method according to any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110530206.5A CN113138883B (en) | 2021-05-14 | 2021-05-14 | Message processing method and device, storage medium and electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110530206.5A CN113138883B (en) | 2021-05-14 | 2021-05-14 | Message processing method and device, storage medium and electronic equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113138883A true CN113138883A (en) | 2021-07-20 |
CN113138883B CN113138883B (en) | 2024-02-02 |
Family
ID=76817904
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110530206.5A Active CN113138883B (en) | 2021-05-14 | 2021-05-14 | Message processing method and device, storage medium and electronic equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113138883B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115314455A (en) * | 2022-08-04 | 2022-11-08 | 中国银行股份有限公司 | Information processing method, device, equipment and medium |
Citations (18)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20020174163A1 (en) * | 2001-04-05 | 2002-11-21 | International Business Machines Corporation | Method, apparatus, and program to keep a JVM running during the shutdown process of a Java based server executing daemon threads |
KR20030035681A (en) * | 2001-11-02 | 2003-05-09 | 엘지전자 주식회사 | method for processing a message of the communication system |
US6687257B1 (en) * | 1999-08-12 | 2004-02-03 | Rockwell Automation Technologies, Inc. | Distributed real-time operating system providing dynamic guaranteed mixed priority scheduling for communications and processing |
CN103888619A (en) * | 2014-04-16 | 2014-06-25 | 青岛海信电子设备股份有限公司 | Message processing method and system thereof |
CN104915253A (en) * | 2014-03-12 | 2015-09-16 | 中国移动通信集团河北有限公司 | Work scheduling method and work processor |
US20180367618A1 (en) * | 2017-06-19 | 2018-12-20 | Sap Se | Event processing in background services |
CN109165114A (en) * | 2018-09-14 | 2019-01-08 | Oppo广东移动通信有限公司 | Processing method, device, storage medium and intelligent terminal of the application program without response |
CN109445927A (en) * | 2018-11-12 | 2019-03-08 | 郑州云海信息技术有限公司 | A kind of task management method and device of storage cluster |
CN109766200A (en) * | 2018-12-31 | 2019-05-17 | 北京明朝万达科技股份有限公司 | A kind of message queue processing method, device, equipment and storage medium |
US20190199648A1 (en) * | 2016-08-31 | 2019-06-27 | Huawei Technologies Co., Ltd. | Broadcast message management method and apparatus |
CN110188016A (en) * | 2019-05-24 | 2019-08-30 | 努比亚技术有限公司 | Detection method, terminal and storage medium of the application program without response obstruction |
CN110662085A (en) * | 2019-10-16 | 2020-01-07 | 北京字节跳动网络技术有限公司 | Message sending method, device, readable medium and electronic equipment |
US20200073709A1 (en) * | 2018-08-30 | 2020-03-05 | Baidu Online Network Technology (Beijing) Co., Ltd. | Method and apparatus for scheduling task, device and medium |
US20200242004A1 (en) * | 2017-10-09 | 2020-07-30 | Huawei Technologies Co., Ltd. | Method for Processing Refresh and Display Exceptions, and Terminal |
CN112181645A (en) * | 2020-09-21 | 2021-01-05 | 中国建设银行股份有限公司 | Resource scheduling method, device, equipment and storage medium |
CN112256458A (en) * | 2020-11-09 | 2021-01-22 | 北京沃东天骏信息技术有限公司 | Message enqueuing method and device, electronic equipment and computer readable medium |
CN112395097A (en) * | 2019-08-14 | 2021-02-23 | 北京京东尚科信息技术有限公司 | Message processing method, device, equipment and storage medium |
CN112596920A (en) * | 2020-12-15 | 2021-04-02 | 中国建设银行股份有限公司 | Message processing method and device, electronic equipment and storage medium |
-
2021
- 2021-05-14 CN CN202110530206.5A patent/CN113138883B/en active Active
Patent Citations (18)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6687257B1 (en) * | 1999-08-12 | 2004-02-03 | Rockwell Automation Technologies, Inc. | Distributed real-time operating system providing dynamic guaranteed mixed priority scheduling for communications and processing |
US20020174163A1 (en) * | 2001-04-05 | 2002-11-21 | International Business Machines Corporation | Method, apparatus, and program to keep a JVM running during the shutdown process of a Java based server executing daemon threads |
KR20030035681A (en) * | 2001-11-02 | 2003-05-09 | 엘지전자 주식회사 | method for processing a message of the communication system |
CN104915253A (en) * | 2014-03-12 | 2015-09-16 | 中国移动通信集团河北有限公司 | Work scheduling method and work processor |
CN103888619A (en) * | 2014-04-16 | 2014-06-25 | 青岛海信电子设备股份有限公司 | Message processing method and system thereof |
US20190199648A1 (en) * | 2016-08-31 | 2019-06-27 | Huawei Technologies Co., Ltd. | Broadcast message management method and apparatus |
US20180367618A1 (en) * | 2017-06-19 | 2018-12-20 | Sap Se | Event processing in background services |
US20200242004A1 (en) * | 2017-10-09 | 2020-07-30 | Huawei Technologies Co., Ltd. | Method for Processing Refresh and Display Exceptions, and Terminal |
US20200073709A1 (en) * | 2018-08-30 | 2020-03-05 | Baidu Online Network Technology (Beijing) Co., Ltd. | Method and apparatus for scheduling task, device and medium |
CN109165114A (en) * | 2018-09-14 | 2019-01-08 | Oppo广东移动通信有限公司 | Processing method, device, storage medium and intelligent terminal of the application program without response |
CN109445927A (en) * | 2018-11-12 | 2019-03-08 | 郑州云海信息技术有限公司 | A kind of task management method and device of storage cluster |
CN109766200A (en) * | 2018-12-31 | 2019-05-17 | 北京明朝万达科技股份有限公司 | A kind of message queue processing method, device, equipment and storage medium |
CN110188016A (en) * | 2019-05-24 | 2019-08-30 | 努比亚技术有限公司 | Detection method, terminal and storage medium of the application program without response obstruction |
CN112395097A (en) * | 2019-08-14 | 2021-02-23 | 北京京东尚科信息技术有限公司 | Message processing method, device, equipment and storage medium |
CN110662085A (en) * | 2019-10-16 | 2020-01-07 | 北京字节跳动网络技术有限公司 | Message sending method, device, readable medium and electronic equipment |
CN112181645A (en) * | 2020-09-21 | 2021-01-05 | 中国建设银行股份有限公司 | Resource scheduling method, device, equipment and storage medium |
CN112256458A (en) * | 2020-11-09 | 2021-01-22 | 北京沃东天骏信息技术有限公司 | Message enqueuing method and device, electronic equipment and computer readable medium |
CN112596920A (en) * | 2020-12-15 | 2021-04-02 | 中国建设银行股份有限公司 | Message processing method and device, electronic equipment and storage medium |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115314455A (en) * | 2022-08-04 | 2022-11-08 | 中国银行股份有限公司 | Information processing method, device, equipment and medium |
Also Published As
Publication number | Publication date |
---|---|
CN113138883B (en) | 2024-02-02 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN113835992B (en) | Memory leakage processing method and device, electronic equipment and computer storage medium | |
CN111240801A (en) | Method, device, medium and electronic equipment for generating heap memory snapshot file | |
CN111625422B (en) | Thread monitoring method, thread monitoring device, electronic equipment and computer readable storage medium | |
CN110618928A (en) | Memory leak detection method and device, terminal equipment and medium | |
CN110727566A (en) | Method, device, medium and electronic equipment for acquiring process crash information | |
CN110851281A (en) | Method, server, terminal, system and storage medium for detecting memory leakage | |
CN113138883B (en) | Message processing method and device, storage medium and electronic equipment | |
CN111596992A (en) | Navigation bar display method and device and electronic equipment | |
CN110727558A (en) | Information prompting method and device, storage medium and electronic equipment | |
CN113518183B (en) | Camera calling method and device and electronic equipment | |
CN115600964A (en) | Voice approval method and device and related equipment | |
CN111625326B (en) | Task pipeline execution method and device and electronic equipment | |
CN111209042B (en) | Method, device, medium and electronic equipment for establishing function stack | |
CN114089891A (en) | Display control method and device and electronic equipment | |
CN112162682A (en) | Content display method and device, electronic equipment and computer readable storage medium | |
CN111309323A (en) | Parameter initialization method and device and electronic equipment | |
CN112306317A (en) | Unread message notification method and device and electronic equipment | |
CN111562913B (en) | Method, device and equipment for pre-creating view component and computer readable medium | |
CN111782410B (en) | Lock jam monitoring method and device, electronic equipment and computer readable medium | |
CN111367555B (en) | Assertion method, assertion device, electronic equipment and computer readable medium | |
CN112486826B (en) | Test method, test device, electronic equipment and computer readable medium | |
CN111694679B (en) | Message processing method and device and electronic equipment | |
CN115827415B (en) | System process performance test method, device, equipment and computer medium | |
CN116701013A (en) | Message consumption method, device, electronic equipment and computer readable medium | |
CN116339846A (en) | Process management method and device, storage medium and electronic equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |