CN113138883B - Message processing method and device, storage medium and electronic equipment - Google Patents

Message processing method and device, storage medium and electronic equipment Download PDF

Info

Publication number
CN113138883B
CN113138883B CN202110530206.5A CN202110530206A CN113138883B CN 113138883 B CN113138883 B CN 113138883B CN 202110530206 A CN202110530206 A CN 202110530206A CN 113138883 B CN113138883 B CN 113138883B
Authority
CN
China
Prior art keywords
message
daemon
main thread
guarded
processing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110530206.5A
Other languages
Chinese (zh)
Other versions
CN113138883A (en
Inventor
汪洋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN202110530206.5A priority Critical patent/CN113138883B/en
Publication of CN113138883A publication Critical patent/CN113138883A/en
Application granted granted Critical
Publication of CN113138883B publication Critical patent/CN113138883B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1415Saving, restoring, recovering or retrying at system level
    • G06F11/1438Restarting 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 present disclosure relates to a message processing method, a device, a storage medium and an electronic apparatus, which determine whether a daemon message exists in a message queue of a main thread, wherein the daemon message is a message with high priority; judging whether the monitored information is unprocessed or not according to the monitoring time corresponding to the monitored information aiming at each determined monitored information, and taking the monitored information as a target monitored information under the condition that the monitored information is unprocessed, wherein the monitoring time corresponding to the monitored information is earlier than or equal to the latest execution time corresponding to the monitored information; when the main thread runs to the anchor point, the anchor point processes the target daemon information, and the anchor point processes the daemon information in time, thereby improving the response performance to the daemon information.

Description

Message processing method and device, storage medium and electronic equipment
Technical Field
The present disclosure relates to the field of message processing, and in particular, to a message processing method, a device, a storage medium, and an electronic apparatus.
Background
In the actual development of the application, different messages have different requirements on execution timing, and in some specific messages, for example, messages related to service components, broadcast components and input types cannot be timely executed, the application is not responded, and ANR (Application Not responding) occurs. The ANR refers to a dialog box displayed to the user by the android system when the response of the application program is not sensitive enough, and the user can select "wait" to let the application program continue to run, or select "forced shutdown". ANR cannot occur in a fluent application to avoid having the user handle this dialog multiple times.
Therefore, the design of response performance for messages with high priority on execution opportunities, such as messages that are prone to ANR, is particularly important in applications.
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, 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 time;
for each determined daemon message, judging whether the daemon message is unprocessed or not at the monitoring moment corresponding to the daemon message, and taking the daemon message as a target daemon message under the condition that the daemon message is unprocessed, wherein the monitoring moment corresponding to the daemon message is earlier than or equal to the latest execution moment corresponding to the daemon message;
and when the main thread runs to an anchor point, processing the target guarded message at the anchor point, wherein a plurality of anchor points are arranged on the main thread.
In a second aspect, the present disclosure provides a message processing apparatus, the apparatus comprising:
a determining module, configured to determine a guarded message in a main thread message queue, where the guarded message is a message with a high priority;
the judging module is used for judging whether the guarded message is unprocessed or not at the monitoring moment corresponding to the guarded message according to each determined guarded message, and taking the guarded message as a target guarded message under the condition that the guarded message is unprocessed, wherein the monitoring moment corresponding to the guarded message is earlier than or equal to the latest execution moment corresponding to the guarded message;
and the processing module is used for processing the target daemon message at the anchor point when the main thread runs to the anchor point, wherein a plurality of anchor points are arranged on the main thread.
In a third aspect, the present disclosure provides a computer readable medium having stored thereon a computer program which when executed by a processing device performs 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 said computer program in said storage means to implement the steps of any of the message processing methods of the first aspect above.
By the technical scheme, the message (the guarded message) which is determined to have high priority in the message queue of the main thread is monitored, the guarded message is used as the target guarded message under the condition that the monitored message is not processed at the monitoring moment corresponding to the guarded message, and when the main thread runs to the anchor point, the target guarded message is processed at the anchor point, and as a plurality of anchor points which are established on the main thread exist, the anchor point can process the guarded message in time, so that the response performance to the guarded message is improved.
Additional features and advantages of the present disclosure will be set forth in the detailed description which follows.
Drawings
The above and other features, advantages, and aspects of embodiments of the present disclosure will become more apparent by reference to the following detailed description when taken in conjunction with the accompanying drawings. The same or similar reference numbers will be used throughout the drawings to refer to the same or like elements. It should be understood that the figures are schematic and that elements and components are not necessarily drawn to scale. In the drawings:
Fig. 1 is a flow chart 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 of a message processing apparatus according to an exemplary embodiment of the present disclosure.
Fig. 4 is a block diagram of 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 have been shown in the accompanying 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 are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustration purposes only and are not intended to limit the scope of the present 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. Furthermore, 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 "including" and variations thereof as used herein are intended to be 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. Related definitions of other terms will be given in the description below.
It should be noted that the terms "first," "second," and the like in this disclosure are merely used to distinguish between different devices, modules, or units and are not used to define an order or interdependence of functions performed by the devices, modules, or units.
It should be noted that references to "one", "a plurality" and "a plurality" in this disclosure are intended to be illustrative rather than limiting, and those of ordinary skill in the art will appreciate that "one or more" is intended to be understood as "one or more" unless the context clearly indicates otherwise.
The names of messages or information interacted between the various devices in the embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
As described in the background, the related art relates particularly to response performance to a message having a high priority in the process of processing the message by a main thread. In view of this, embodiments of the present disclosure provide a message processing method, apparatus, storage medium, and 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 flow chart illustrating a message processing method according to an exemplary embodiment of the present disclosure. Referring to fig. 1, the message processing method may include:
step 101, a guarded message in a main thread message queue is determined.
Step 102, for each determined daemon message, determining whether the daemon message is unprocessed at the monitoring time corresponding to the daemon message, and regarding the daemon message as a target daemon message when the daemon message is determined to be unprocessed.
Step 103, when the main thread runs to an anchor point, processing the target daemon message at the anchor point.
It should be noted that the daemon message is a message with a high priority. A message with a higher priority is a message that needs to be responded to in time more than a message with a lower 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 at the latest execution time corresponding to the message. It should be noted that the message that will cause ANR in case the corresponding latest execution time is not yet processed may be, for example, a message related to a Service component, a Receiver component in an android application, for example, a message related to an input type.
Embodiments of the present disclosure will be further explained below with daemon messages as messages that will cause ANR.
Illustratively, the monitored time corresponding to the daemon message is earlier than or equal to the latest execution time corresponding to the daemon message. In view of the fact that a certain processing time is required for judging whether the guarded message has been processed, the monitoring time can be set to a time earlier than the latest execution time corresponding to the guarded message, and whether the guarded message has been processed is judged at a time earlier than the latest execution time corresponding to the guarded message, so that the probability of ANR caused by that the guarded message has not been processed later is effectively reduced.
For example, the monitoring time may be a time corresponding to a preset time length of the latest execution time corresponding to the daemon message. The preset time period may be set according to actual situations, which is not limited in this embodiment.
In the present disclosure, a plurality of anchor points are provided on a main thread. For example, the execution time of the anchor point may be set to a handoff neutral time to process two messages.
It should be noted that the above method steps may be performed at the start-up run of the main thread.
By the method, the message (the guarded message) which is determined to cause the ANR in the message queue of the main thread is monitored, the guarded message is taken as the target guarded message when the monitored moment corresponding to the guarded message is determined that the guarded message is not processed, and when the main thread runs to the anchor point, the target guarded message is processed at the anchor point, and as a plurality of anchor points which are established on the main thread exist, the guarded message can be processed by the anchor point in time, the response performance to the guarded message is improved, and the situation that the ANR is caused because the guarded message is not processed at a delayed time is avoided.
In order to make those skilled in the art more understand the message processing method provided in the present disclosure, the following details of the above steps are illustrated.
In a possible implementation, the daemon messages comprise service type, broadcast type and/or input type messages.
In a possible implementation, 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 appreciated that each message carries a field that characterizes the type of message that can be obtained by obtaining and analyzing this field.
Next, messages in the message queue for which the message type is a service type, a broadcast type, and/or an input type are determined to be messages that will cause ANR to obtain a daemon message.
By way of example, 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 related to a Receiver component in an android application.
In the use of android applications, each text box corresponds to a particular type of text input, such as Email address, phone number, or plain text. It is important to specify the type of input for each text box in the application, which can allow the system to display a more appropriate soft input method (such as a virtual keyboard), and such a message can be used as an ANR-causing message because of the higher timeliness requirement of the display of the input method, that is, the higher timeliness requirement of processing the message that allows the system to display what input method.
In a possible manner, the main thread adds an anchor within each message in the message queue as it processes the message. In this case, step 103 shown in FIG. 1 may include processing the target daemon message at an anchor point within the message currently being processed by the main thread.
In this embodiment, when the main thread processes each message in the message queue, an anchor point is added in the message, and when the main thread runs the anchor point in the currently processed message, the method is equivalent to directly placing the target protected message in the message pointed by the anchor point for execution, compared with the strategy of processing the target protected message by using other anchor points of the main thread, the method can effectively increase the probability that the target protected message is executed in advance by using the anchor point in the currently processed message, thus effectively reducing the probability that the protected message is not processed in delay to cause ANR.
In a possible implementation manner, in the case where it is determined that the daemon message is not processed in step 102 shown in fig. 1, the targeting the daemon message as the target daemon message may specifically include: in the event that the daemon message is determined to be unprocessed, the daemon message is added to the urgent queue. Wherein the urgent queue is used to store the target daemon message. In this case, step 103 shown in fig. 1 may include: and when the main thread runs to each anchor point, the target guarded message is taken out of the emergency queue in sequence for processing.
It should be noted that messages in the urgent queue are preferentially processed by the main thread over messages in the main thread's message queue.
In this way, in the above-mentioned manner, in the process of the anchor point processing of the last determined target-being-daemon message being currently executed, a plurality of target-being-daemon messages are determined again, in which case, in order to ensure that each target-being-daemon message determined in this process is preferentially processed by the anchor point in turn, an urgent queue may be provided for storing the determined target-being-daemon message, and since the message in the urgent queue is preferentially processed compared with the message in the message queue of the main thread, the anchor point preferentially processes the target-being-daemon message stored in the urgent queue until there is no target-being-daemon message in the urgent queue to be processed.
In a possible embodiment, step 102 shown in fig. 1 may include: judging whether the daemon message exists in a message queue of the main thread or not at the monitoring moment corresponding to the daemon message aiming at each determined daemon message; in the event that the presence of the daemon message in the message queue of the main thread is determined, the daemon message is determined to be unprocessed and is treated 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 guarded messages include message a, message C, and message F, the message present in the current message queue of the main thread includes message B, message C, message E, message F, and message G, and at the monitoring time of message a, since message a is not present in the message queue of the main thread, it is determined that message a has been or is being processed without the need for daemon.
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 needs to be daemon, that is, the message C needs to be daemon as a target, and when the main thread runs to an anchor point, the message C is processed at the anchor point.
In this embodiment, considering the feature that the message queue disappears from the message queue after the message is fetched (the message is processed), it is possible to determine whether the daemon message exists in the message queue of the main thread, thereby determining whether the daemon message has been processed.
In a possible implementation manner, the message processing method further includes: creating a daemon thread; after each daemon message is determined, a daemon message associated with the daemon message is created and the processing time of the daemon message is set.
Wherein the processing time of the daemon message is equal to the monitoring time corresponding to the daemon message associated with the daemon message.
In this embodiment, the daemon thread is another thread different from the main thread, and is configured to process each daemon message at the processing time of the daemon message, so as to determine whether the daemon message associated with the daemon message is unprocessed, and in a case that it is determined that the daemon message is unprocessed, regard the daemon message as a target daemon message.
In a possible implementation, the daemon thread is also used to: traversing all messages in a message queue of a main thread to obtain information characteristics of all messages in the message queue of the main thread; and determining a message corresponding to the information feature as a guarded message under the condition that any acquired information feature comprises a preset information feature.
It should be appreciated that each message has some information characteristics that are different from other types of messages. Therefore, according to the information characteristics and the preset information characteristics of all the messages in the message queue, whether all the messages in the message queue are guarded messages can be judged.
It should be noted that the preset information characteristics of the service type, broadcast type input type messages are different.
Still further explanation of this embodiment is provided with respect to FIG. 2, where message C, message F, and message A are messages in the message queue of the main thread that are determined to cause ANR, i.e., daemon 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 executing the messages in the message queue of the main thread is as follows: message B- & gt message C- & gt message E- & gt message F- & gt message G, and the arrow direction on the main thread represents the moving direction of each anchor point and also represents the sequence of each anchor point in turn. The message currently being processed is message B, with anchor 1 being established inside message B, anchor 2 being established between message B and message C of the main thread, and similarly to anchor 1 and anchor 2, there are also anchor 3, anchor 4, anchor 5, anchor 6, anchor 7.
In fig. 2, message C is found to be also stored in the message queue of the main thread at its monitoring instant, i.e. when the daemon thread processes the daemon message associated with message C at the processing instant (equal to the monitoring instant), i.e. not yet processed. Thus, message C is determined to be the target daemon message. In this case, since the anchor 1 is provided inside the message B, when the anchor 1 is running, the message C can be processed at the anchor 1, so as to avoid ANR caused by untimely processing of the message C.
If an anchor is not established within message B in fig. 2, message C may be processed at anchor 2 when running to that anchor 2.
Based on the same inventive concept, the embodiments of the present disclosure also provide a message processing apparatus, which may be 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 guarded message in the main thread message queue, where the guarded message is a message with a high priority on an execution opportunity.
A judging module 302, configured to judge, for each of the determined daemon messages, whether the daemon message is unprocessed at a monitoring time corresponding to the daemon message, and regarding the daemon message as a target daemon message if it is determined that the daemon message is unprocessed, 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 303 is configured to process the target daemon message at an anchor point when the main thread runs to the anchor point, where a plurality of anchor points are set on the main thread.
Optionally, the daemon message comprises: a service type, a broadcast type, and/or an input type message.
Optionally, the message processing apparatus 300 further includes:
and the adding module is used for adding an anchor point in each message in the message queue when the main thread processes the message.
The processing module 303 is configured to:
when the main thread runs an anchor within the currently processed message, the target daemon message is processed at the anchor.
Optionally, the determining module 301 is configured to:
in the event that the daemon message is determined to be unprocessed, the daemon message is added to an emergency queue for storing the target daemon message.
The processing module 303 is configured to:
and when the main thread runs to each anchor point, the target guarded message is taken out of the emergency queue in sequence for processing.
Optionally, the judging module 302 is configured to:
judging whether the daemon message exists in a message queue of the main thread or not at the monitoring moment corresponding to the daemon message aiming at each determined daemon message;
determining that the daemon message is not processed if the daemon message exists in the message queue of the main thread; and is combined with the other components of the water treatment device,
The daemon message is targeted to the daemon message.
Optionally, the message processing apparatus 300 further includes:
and the first creation module is used for creating daemon threads.
The second creating module is used for creating a daemon message associated with each daemon message after each daemon message is determined, and setting the processing time of the daemon message, wherein the daemon message is used for processing by the daemon thread, and the processing time is the 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 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 obtain the information characteristics of all the messages in the message queue of the main thread; and is combined with the other components of the water treatment device,
and under the condition that any acquired information characteristic comprises a preset information characteristic, determining a message corresponding to the information characteristic as the guarded message.
Based on the same inventive concept, the embodiments of the present disclosure also provide a computer readable medium having stored thereon a computer program which, when executed by a processing device, implements the steps of any of the message processing methods described above.
Based on the same inventive concept, the embodiments of the present disclosure further provide an electronic device, including:
a storage device having a computer program stored thereon;
processing means for executing said computer program in said storage means to implement the steps of any of the message processing methods described above.
Referring now to fig. 4, a schematic diagram of an electronic device 400 suitable for use in implementing embodiments of the present disclosure is shown. The terminal devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and the like, and stationary terminals such as digital TVs, desktop computers, and the like. The electronic device shown in fig. 4 is merely an example and should not be construed to limit the functionality and scope of use of the disclosed embodiments.
As shown in fig. 4, the electronic device 400 may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 401, which may perform various suitable actions and processes according to a program stored in a Read Only Memory (ROM) 402 or a program loaded from a storage means 408 into a Random Access Memory (RAM) 403. In the RAM 403, various programs and data necessary for the operation of the electronic device 400 are also stored. The processing device 401, the ROM 402, and the RAM 403 are connected to each other by a bus 404. An input/output (I/O) interface 405 is also connected to bus 404.
In general, the following devices may be connected to the I/O interface 405: input devices 406 including, for example, a touch screen, touchpad, 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, magnetic tape, hard disk, etc.; and a communication device 409. The communication means 409 may allow the electronic device 400 to communicate with other devices wirelessly or by wire to exchange data. While fig. 4 shows an electronic device 400 having various means, it is to be understood that not all of the illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a non-transitory computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via communications device 409, or from storage 408, or from ROM 402. The above-described functions defined in the methods of the embodiments of the present disclosure are performed when the computer program is executed by the processing device 401.
It should be noted that the computer readable medium described in the present disclosure may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any 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 context of this 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 the present disclosure, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. 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, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
In some implementations, communications may be made 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 networks.
The computer readable medium may be contained in the electronic device; or may exist alone without being incorporated 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 time; for each determined daemon message, judging whether the daemon message is unprocessed or not at the monitoring moment corresponding to the daemon message, and taking the daemon message as a target daemon message under the condition that the daemon message is unprocessed, wherein the monitoring moment corresponding to the daemon message is earlier than or equal to the latest execution moment corresponding to the daemon message; and when the main thread runs to an anchor point, processing the target guarded message at the anchor point, wherein a plurality of anchor points are arranged on the main thread.
Computer program code for carrying out operations of the present disclosure may be written in 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 kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts 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 in software or hardware. The name of a module does not in some cases define the module itself.
The functions described above herein 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: a Field Programmable Gate Array (FPGA), an Application Specific Integrated Circuit (ASIC), an Application Specific Standard Product (ASSP), a system on a chip (SOC), a Complex Programmable Logic Device (CPLD), 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. The 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.
According to one or more embodiments of the present disclosure, example 1 provides a message processing method, including:
determining a guarded message in a main thread message queue, wherein the guarded message has a message with high priority to execution time;
for each determined daemon message, judging whether the daemon message is unprocessed or not at the monitoring moment corresponding to the daemon message, and taking the daemon message as a target daemon message under the condition that the daemon message is unprocessed, wherein the monitoring moment corresponding to the daemon message is earlier than or equal to the latest execution moment corresponding to the daemon message;
and when the main thread runs to an anchor point, processing the target guarded message at the anchor point, wherein a plurality of anchor points are arranged on the main thread.
Example 2 provides the method of example 1, according to one or more embodiments of the present disclosure, the daemon message comprising: a service type, a broadcast type, and/or an input type message.
Example 3 provides the method of example 1, according to one or more embodiments of the present disclosure, the main thread adding an anchor point within each message in the message queue as it is processed;
Said processing said target daemon message at an anchor point when said main thread runs to the anchor point, comprising:
when the main thread runs an anchor within the currently processed message, the target daemon message is processed at the anchor.
In accordance with one or more embodiments of the present disclosure, example 4 provides the method of example 1, the 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 it is determined that the daemon message is not processed, adding the daemon message to an emergency queue for storing target daemon messages;
said processing said target daemon message at an anchor point when said main thread runs to the anchor point, comprising:
and when the main thread runs to each anchor point, the target guarded message is taken out of the emergency queue in sequence for processing.
According to one or more embodiments of the present disclosure, example 5 provides the method of example 1, wherein for each of the determined daemon messages, determining whether the daemon message is unprocessed at a monitoring time corresponding to the daemon message, and in a case where it is determined that the daemon message is unprocessed, regarding the daemon message as a target daemon message, includes:
Judging whether the daemon message exists in a message queue of the main thread or not at the monitoring moment corresponding to the daemon message aiming at each determined daemon message;
determining that the daemon message is not processed if the daemon message exists in the message queue of the main thread; and is combined with the other components of the water treatment device,
the daemon message is targeted to the daemon message.
According to one or more embodiments of the present disclosure, example 6 provides the method of any one of examples 1-5, the method further comprising:
creating a daemon thread;
after each daemon message is determined, creating a daemon message associated with the daemon message and setting the processing time of the daemon message, wherein the daemon message is used for processing by the daemon thread, and the processing time is the 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 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, according to one or more embodiments of the present disclosure, the daemon thread further to:
traversing all messages in the message queue of the main thread to obtain the information characteristics of all the messages in the message queue of the main thread; and is combined with the other components of the water treatment device,
and under the condition that any acquired information characteristic comprises a preset information characteristic, determining a message corresponding to the information characteristic as the guarded message.
According to one or more embodiments of the present disclosure, example 8 provides a message processing apparatus, the apparatus comprising:
and the determining module is used for determining the guarded message in the main thread message queue, wherein the guarded message is a message with high priority on the execution occasion.
The judging module is used for judging whether the guarded message is unprocessed or not at the monitoring moment corresponding to the guarded message according to each determined guarded message, and taking the guarded message as a target guarded message under the condition that the guarded message is unprocessed, wherein the monitoring moment corresponding to the guarded message is earlier than or equal to the latest execution moment corresponding to the guarded message.
And the processing module is used for processing the target daemon message at the anchor point when the main thread runs to the anchor point, wherein a plurality of anchor points are arranged on the main thread.
Example 9 provides the apparatus of example 8, according to one or more embodiments of the disclosure, the daemon message comprising: a service type, a broadcast type, and/or an input type message.
According to one or more embodiments of the present disclosure, example 10 provides the apparatus of example 8, the message processing apparatus further comprising:
and the adding module is used for adding an anchor point in each message in the message queue when the main thread processes the message.
The processing module is used for:
when the main thread runs an anchor within the currently processed message, the target daemon message is processed at the anchor.
Example 11 provides the apparatus of example 8, according to one or more embodiments of the disclosure, the determining module to:
in the event that the daemon message is determined to be unprocessed, the daemon message is added to an emergency queue for storing the target daemon message.
The processing module is used for:
and when the main thread runs to each anchor point, the target guarded message is taken out of the emergency queue in sequence for processing.
Example 12 provides the apparatus of example 8, according to one or more embodiments of the disclosure, the determining module to:
Judging whether the daemon message exists in a message queue of the main thread or not at the monitoring moment corresponding to the daemon message aiming at each determined daemon message;
determining that the daemon message is not processed if the daemon message exists in the message queue of the main thread; and is combined with the other components of the water treatment device,
the daemon message is targeted to the daemon message.
According to one or more embodiments of the present disclosure, example 13 provides the apparatus of any one of examples 8-12, the message processing apparatus further comprising:
and the first creation module is used for creating daemon threads.
The second creating module is used for creating a daemon message associated with each daemon message after each daemon message is determined, and setting the processing time of the daemon message, wherein the daemon message is used for processing by the daemon thread, and the processing time is the 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 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, according to one or more embodiments of the disclosure, the daemon thread further to:
traversing all messages in the message queue of the main thread to obtain the information characteristics of all the messages in the message queue of the main thread; and is combined with the other components of the water treatment device,
and under the condition that any acquired information characteristic comprises a preset information characteristic, determining a message corresponding to the information characteristic as the guarded message.
According to one or more embodiments of the present disclosure, example 15 provides a computer-readable medium having stored thereon a computer program which, when executed by a processing device, implements the steps of the method of any of examples 1 to 7.
Example 16 provides an electronic device according to one or more embodiments of the present disclosure, 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 method of any one of examples 1 to 7.
The foregoing description is only of the preferred embodiments of the present disclosure and description of the principles of the technology being employed. It will be appreciated by persons skilled in the art that the scope of the disclosure referred to in this disclosure is not limited to the specific combinations of features described above, but also covers other embodiments which may be formed by any combination of features described above or equivalents thereof without departing from the spirit of the disclosure. Such as those described above, are mutually substituted with the technical features having similar functions disclosed in the present disclosure (but not limited thereto).
Moreover, although 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. In 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 limiting the scope of the present 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 example forms of implementing the claims. The specific manner in which the various modules perform the operations in the apparatus of the above embodiments have been described in detail in connection with the embodiments of the method, and will not be described in detail herein.

Claims (9)

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 time;
for each determined daemon message, judging whether the daemon message is unprocessed or not at the monitoring moment corresponding to the daemon message, and taking the daemon message as a target daemon message under the condition that the daemon message is unprocessed, wherein the monitoring moment corresponding to the daemon message is earlier than or equal to the latest execution moment corresponding to the daemon message;
when the main thread runs to an anchor point, processing the target guarded message at the anchor point, wherein a plurality of anchor points are arranged on the main thread;
the main thread adds an anchor point in each message in the message queue when processing the message; said processing said target daemon message at an anchor point when said main thread runs to the anchor point, comprising: when the main thread runs an anchor within the currently processed message, the target daemon message is processed at the anchor.
2. The method of claim 1, wherein the daemon message comprises: a service type, a broadcast type, and/or an input type message.
3. The method of claim 1, wherein the targeting the daemon message as the target daemon message if it is determined that the daemon message is not processed comprises:
in the event that it is determined that the daemon message is not processed, adding the daemon message to an emergency queue for storing target daemon messages;
said processing said target daemon message at an anchor point when said main thread runs to the anchor point, comprising:
and when the main thread runs to each anchor point, the target guarded message is taken out of the emergency queue in sequence for processing.
4. The method according to claim 1, wherein for each of the daemon messages determined, determining whether the daemon message is unprocessed at a monitoring time corresponding to the daemon message, and in a case where it is determined that the daemon message is unprocessed, regarding the daemon message as a target daemon message, comprises:
judging whether the daemon message exists in a message queue of the main thread or not at the monitoring moment corresponding to the daemon message aiming at each determined daemon message;
Determining that the daemon message is not processed if the daemon message exists in the message queue of the main thread; and is combined with the other components of the water treatment device,
the daemon message is targeted to the daemon message.
5. The method according to any one of claims 1-4, further comprising:
creating a daemon thread;
after each daemon message is determined, creating a daemon message associated with the daemon message and setting the processing time of the daemon message, wherein the daemon message is used for processing by the daemon thread, and the processing time is the 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 takes the daemon message as a target daemon message under the condition that the daemon message is determined to be unprocessed.
6. The method of claim 5, wherein the daemon thread is further to:
traversing all messages in the message queue of the main thread to obtain the information characteristics of all the messages in the message queue of the main thread; and is combined with the other components of the water treatment device,
And under the condition that any acquired information characteristic comprises a preset information characteristic, determining a message corresponding to the information characteristic as the guarded message.
7. A message processing apparatus, the apparatus comprising:
the determining module is used for determining the guarded message in the main thread message queue, wherein the guarded message is a message with high priority to the execution time;
the judging module is used for judging whether the guarded message is unprocessed or not at the monitoring moment corresponding to the guarded message according to each determined guarded message, and taking the guarded message as a target guarded message under the condition that the guarded message is unprocessed, wherein the monitoring moment corresponding to the guarded message is earlier than or equal to the latest execution moment corresponding to the guarded message;
the processing module is used for processing the target daemon message at an anchor point when the main thread runs to the anchor point, wherein a plurality of anchor points are arranged on the main thread;
the message processing apparatus further includes: an adding module, configured to add an anchor point in each message in the message queue when the main thread processes the message;
The processing module is configured to, if it is determined that the daemon message is not processed, add the daemon message to an emergency queue that is used to store a target daemon message.
8. A computer readable medium on which a computer program is stored, characterized in that the program, when being executed by a processing device, carries out the steps of the method according to any one of claims 1-6.
9. An electronic device, comprising:
a storage device having a computer program stored thereon;
processing means for executing said computer program in said storage means to carry out the steps of the method according to any one of claims 1-6.
CN202110530206.5A 2021-05-14 2021-05-14 Message processing method and device, storage medium and electronic equipment Active CN113138883B (en)

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 CN113138883A (en) 2021-07-20
CN113138883B true 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)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115314455A (en) * 2022-08-04 2022-11-08 中国银行股份有限公司 Information processing method, device, equipment and medium

Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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
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
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
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

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6918114B2 (en) * 2001-04-05 2005-07-12 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
CN107800546B (en) * 2016-08-31 2021-03-30 华为技术有限公司 Management method and device for broadcast messages
US10652338B2 (en) * 2017-06-19 2020-05-12 Sap Se Event processing in background services
WO2019071626A1 (en) * 2017-10-09 2019-04-18 华为技术有限公司 Method for processing refreshing display abnormality, and terminal
CN109117260B (en) * 2018-08-30 2021-01-01 百度在线网络技术(北京)有限公司 Task scheduling method, device, equipment and medium

Patent Citations (13)

* Cited by examiner, † Cited by third party
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
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
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

Also Published As

Publication number Publication date
CN113138883A (en) 2021-07-20

Similar Documents

Publication Publication Date Title
CN111488185B (en) Page data processing method, device, electronic equipment and readable medium
CN113835992B (en) Memory leakage processing method and device, electronic equipment and computer storage medium
JP7467644B2 (en) Message processing method, device and electronic device
CN111240834B (en) Task execution method, device, electronic equipment and storage medium
CN110633126B (en) Information display method and device and electronic equipment
CN112379982B (en) Task processing method, device, electronic equipment and computer readable storage medium
CN111625422B (en) Thread monitoring method, thread monitoring device, electronic equipment and computer readable storage medium
CN111432001B (en) Method, apparatus, electronic device and computer readable medium for jumping scenes
CN111259636B (en) Document rendering method and device and electronic equipment
CN110865846B (en) Application management method, device, terminal, system and storage medium
CN113138883B (en) Message processing method and device, storage medium and electronic equipment
CN111258582B (en) Window rendering method and device, computer equipment and storage medium
CN111596992B (en) Navigation bar display method and device and electronic equipment
CN111459893B (en) File processing method and device and electronic equipment
CN111625326B (en) Task pipeline execution method and device and electronic equipment
CN113518183A (en) Camera calling method and device and electronic equipment
CN112162682A (en) Content display method and device, electronic equipment and computer readable storage medium
CN112333462A (en) Live broadcast room page jumping method, returning device and electronic equipment
CN111562913B (en) Method, device and equipment for pre-creating view component and computer readable medium
CN111367555B (en) Assertion method, assertion device, electronic equipment and computer readable medium
CN111694679B (en) Message processing method and device and electronic equipment
CN112764941B (en) Resource access method, device, electronic equipment and computer readable storage medium
CN111324512B (en) Method, apparatus, electronic device, and computer-readable medium for generating text
CN110750242B (en) File deployment method, system, medium and electronic equipment
CN117076082A (en) Scheduling method and device of drawing canvas, 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