CN112711490A - Message processing method, computing device and storage medium - Google Patents

Message processing method, computing device and storage medium Download PDF

Info

Publication number
CN112711490A
CN112711490A CN202110323157.8A CN202110323157A CN112711490A CN 112711490 A CN112711490 A CN 112711490A CN 202110323157 A CN202110323157 A CN 202110323157A CN 112711490 A CN112711490 A CN 112711490A
Authority
CN
China
Prior art keywords
observer
notification message
queue
processing
queues
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
Application number
CN202110323157.8A
Other languages
Chinese (zh)
Other versions
CN112711490B (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.)
Uniontech Software Technology Co Ltd
Original Assignee
Uniontech Software 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 Uniontech Software Technology Co Ltd filed Critical Uniontech Software Technology Co Ltd
Priority to CN202110624782.6A priority Critical patent/CN113312189A/en
Priority to CN202110323157.8A priority patent/CN112711490B/en
Publication of CN112711490A publication Critical patent/CN112711490A/en
Application granted granted Critical
Publication of CN112711490B publication Critical patent/CN112711490B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5022Mechanisms to release resources
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q10/00Administration; Management
    • G06Q10/10Office automation; Time management
    • G06Q10/107Computer-aided management of electronic mailing [e-mailing]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L51/00User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
    • H04L51/42Mailbox-related aspects, e.g. synchronisation of mailboxes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/548Queue

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • General Physics & Mathematics (AREA)
  • Business, Economics & Management (AREA)
  • Physics & Mathematics (AREA)
  • Human Resources & Organizations (AREA)
  • General Engineering & Computer Science (AREA)
  • Strategic Management (AREA)
  • Entrepreneurship & Innovation (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Data Mining & Analysis (AREA)
  • Computer Hardware Design (AREA)
  • Signal Processing (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Operations Research (AREA)
  • Quality & Reliability (AREA)
  • Tourism & Hospitality (AREA)
  • General Business, Economics & Management (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention discloses a message processing method, a computing device and a storage medium, wherein the method responds to user operation and generates a notification message; searching for an observer queue corresponding to the message type of the generated notification message, accessing one of the searched observer queues, and processing the notification message by using an observer in the observer queue; and judging whether a new observer is generated in the process of processing the notification message, if so, adding the new observer into another searched observer queue which is not accessed currently, and if not, continuing to execute the step of judging whether a new observer is generated in the process of processing the notification message. By the method, when a new observer is generated, the accessed observer queue is staggered, the new observation is stored in another observer queue corresponding to the type of the notification message, and the stability of the observer queue in the process of processing the notification message is ensured.

Description

Message processing method, computing device and storage medium
Technical Field
The present invention relates to the field of message processing technologies, and in particular, to a message processing system, a computing device, and a storage medium.
Background
An Application program (Application) is a collection of programs that can be used by a user in various programming languages, and that are written in various programming languages. The application program can meet the application requirements of different fields and different problems, so that the application program is more and more widely used. In the design and development of the application program, a plurality of functional modules are included, and mutual notification of messages is performed among the functional modules.
At present, a message notification class is designed in an intermediate layer of an application program, and maintains two classes of queues, one class is a notification message queue and the other class is a plurality of observer queues, wherein the notification message queue comprises a plurality of types of notification messages, the observer queues consume the notification messages in the message queue, one notification message type corresponds to one observer queue, and a functional module inherited from the notification message can register itself in the observer queue of the notification message of the corresponding type, so as to receive the notification messages sent by other functional modules or the functional module. When detecting that the notification message comes in the message queue, traversing the observer queue corresponding to the type of notification message, and sequentially calling the processing function of the observer in the observer queue for the type of notification message to complete the processing of the notification message. However, the observer queue is often unstable during the process of processing the notification message by the observer, which easily causes the application to crash.
For this reason, a message processing method is needed to solve the problem that the application program is unstable when processing the message in the above technical solution.
Disclosure of Invention
To this end, the present invention provides a message processing method in an attempt to solve or at least alleviate the above-presented problems.
According to an aspect of the present invention, there is provided a message processing method adapted to be executed in a computing device, the method comprising the steps of:
generating a notification message in response to a user operation;
searching for watcher queues corresponding to message types of the generated notification messages, wherein each type of notification message corresponds to two watcher queues;
accessing one of the found observer queues and processing the notification message by using the observers in the observer queue;
and judging whether a new observer is generated in the process of processing the notification message, if so, adding the new observer into another searched observer queue which is not accessed currently, and if not, accessing one of the searched observer queues and processing the notification message by using the observers in the observer queues.
Optionally, the method further comprises the steps of:
judging whether a request for deleting the observer is generated in the process of processing the notification message by using the observer, if so, judging whether the observer to be deleted is in an observer queue for processing the notification message, and if not, executing a step of judging whether the request for deleting the observer is generated in the process of processing the notification message by using the observer;
wherein the step of determining whether the watcher to be deleted is in the watcher queue for handling notification messages comprises:
and judging whether the observer to be deleted is in an observer queue for processing the notification message, if so, setting the node of the observer to be deleted to be empty, and if not, deleting the observer to be deleted.
Optionally, the determining whether a new watcher is generated in the process of processing the notification message, and if so, adding the new watcher to another currently unvisited and looked up watcher queue includes:
judging whether a new observer is generated in the process of processing the notification message, if so, determining another searched observer queue which is not accessed currently according to the member variable identifier of the observer queue, and if not, executing the step of judging whether a new observer is generated in the process of processing the notification message, wherein the observer queue accessed currently is distinguished through the member variable identifier;
and judging whether an observer with an empty node exists in the other searched observer queue which is not accessed, if so, replacing the observer with the empty node with a new observer, and if not, adding the new observer into the other searched observer queue which is not accessed.
Optionally, the step of generating a notification message in response to a user operation includes:
generating a notification message in response to the operation of the functional module by the user;
wherein the step of accessing one of the found watcher queues and processing the notification message with the watchers in the watcher queue comprises: accessing one of the searched observer queues to search for an observer registered to the functional module;
processing the notification message by the found watcher registered to the functional module.
Optionally, the method further comprises the step of:
setting a flag bit for the new observer;
and setting the set flag bit, wherein the watchers with the set flag bit are skipped in the process of accessing the found one of the watcher queues.
Optionally, when the notification message is generated, the generated notification message is further saved to a message queue, and the method further includes the steps of:
and judging whether a new notification message reaches the message queue, if so, searching the observer queue corresponding to the message type of the notification message, and resetting the observer flag bit in the searched observer queue, wherein an observer with the reset flag bit is accessed in the process of accessing one of the searched observer queues.
Optionally, two watcher queues corresponding to notification message types are distinguished according to member variable names of the watchers, wherein the message types of the notification messages comprise one or more of mail arrival, mail selection, mail sending, mail deletion, account creation and account deletion.
According to another aspect of the present invention, there is provided a method of processing a message in a mail system, wherein the message is a message in the mail system, the method comprising the steps of:
responding to the operation of a user on each mail function module in the mail system, and generating a mail notification message;
searching for observer queues corresponding to message types of the generated mail notification messages, wherein each type of notification message corresponds to two observer queues;
accessing one of the found observer queues, and processing the mail notification message by using the observers in the observer queues;
and judging whether a new observer is generated in the process of processing the mail notification message, if so, adding the new observer into another searched observer queue which is not accessed currently, and if not, executing the step of accessing one of the searched observer queues and processing the mail notification message by using the observers in the observer queues.
According to another aspect of the present invention, there is provided a computing device comprising: at least one processor; and a memory storing program instructions, wherein the program instructions are configured to be executed by the at least one processor, the program instructions comprising instructions for performing the method as described above.
According to yet another aspect of the present invention, there is provided a readable storage medium storing program instructions which, when read and executed by a computing device, cause the computing device to perform the method as described above.
According to the technical scheme of the invention, a message processing method is provided, wherein one notification message type corresponds to two observer queues, so that when a new observer is generated, the accessed observer queues are staggered, the new observation is stored in the other observer queue corresponding to the notification message type, and the stability of the observer queues in the process of processing the notification message is ensured. Specifically, in response to a user operation, a notification message is generated, two observer queues corresponding to message types of the generated notification message are searched, one of the searched observer queues is accessed, the notification message is processed by using the observers in the observer queues, whether a new observer is generated or not in the process of processing the notification message is judged, and if yes, the new observer is added into the other searched observer queue which is not accessed currently.
Drawings
To the accomplishment of the foregoing and related ends, certain illustrative aspects are described herein in connection with the following description and the annexed drawings, which are indicative of various ways in which the principles disclosed herein may be practiced, and all aspects and equivalents thereof are intended to be within the scope of the claimed subject matter. The above and other objects, features and advantages of the present disclosure will become more apparent from the following detailed description read in conjunction with the accompanying drawings. Throughout this disclosure, like reference numerals generally refer to like parts or elements.
FIG. 1 shows a schematic diagram of a computing device 100, according to one embodiment of the invention;
FIG. 2 shows a flow diagram of a message processing method 200 according to one embodiment of the invention;
3a-3b illustrate diagrams of a viewer queue data structure, according to one embodiment of the invention; and
fig. 4 shows a flow diagram of a message processing method 300 according to another embodiment of the invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
In the prior art, in the design and development of an application program, a plurality of functional modules are included, and mutual notification of messages is performed among the functional modules. At present, a message notification class is designed in an intermediate layer of an application program, and maintains two classes of queues, one class is a notification message queue and the other class is a plurality of observer queues, wherein the notification message queue includes a plurality of types of notification messages, the observer queues consume the notification messages of the message queue, one notification message type corresponds to one observer queue, and a functional module inherited from the notification message can register itself in the observer queue of the notification message of the corresponding type, so as to receive the notification message sent by other functional modules or the functional module. When the notification message arrives, traversing an observer queue corresponding to the message type of the notification message, and sequentially calling the processing function of the observer in the observer queue for the notification message to complete the processing of the notification message. The watchers are functional modules registered in corresponding types and watcher queues, and each functional module is responsible for receiving the notification messages sent by other modules or the module and processing the notification messages.
However, in the process of processing notification messages by watchers, new watchers are created or existing watchers are deleted, so that the queue of the watchers being accessed is changed, the queue of the watchers is not stable any more, and the application program is crashed due to the failure of the index or pointer of the watchers during access. Moreover, the above processes are performed in one thread, and the above problems cannot be solved by locking.
To this end, the present invention proposes a message processing method, in which one notification message type corresponds to two observer queues, so that when a new observer is generated, the observer queues being accessed are staggered, and the new observation is saved in another observer queue corresponding to the notification message type, thereby ensuring the stability of the observer queues in the process of processing the notification message. Specifically, in response to a user operation, a notification message is generated, two observer queues corresponding to message types of the generated notification message are searched, one of the searched observer queues is accessed, the notification message is processed by using the observers in the observer queues, whether a new observer is generated or not in the process of processing the notification message is judged, and if yes, the new observer is added into the other searched observer queue which is not accessed currently.
The message processing method provided by the invention is executed in a computing device, and fig. 1 shows a block diagram of a computing device 100 according to an embodiment of the invention. A block diagram of a computing device 100 As shown in FIG. 1, in a basic configuration 102, the computing device 100 typically includes a system memory 106 and one or more processors 104. A memory bus 108 may be used for communication between the processor 104 and the system memory 106.
Depending on the desired configuration, the processor 104 may be any type of processing, including but not limited to: a microprocessor (μ P), a microcontroller (μ C), a digital information processor (DSP), or any combination thereof. The processor 104 may include one or more levels of cache, such as a level one cache 110 and a level two cache 112, a processor core 114, and registers 116. The example processor core 114 may include an Arithmetic Logic Unit (ALU), a Floating Point Unit (FPU), a digital signal processing core (DSP core), or any combination thereof. The example memory controller 118 may be used with the processor 104, or in some implementations the memory controller 118 may be an internal part of the processor 104.
Depending on the desired configuration, system memory 106 may be any type of memory, including but not limited to: volatile memory (such as RAM), non-volatile memory (such as ROM, flash memory, etc.), or any combination thereof. System memory 106 may include an operating system 120, one or more applications 122, and program data 124. In some embodiments, application 122 may be arranged to operate with program data 124 on an operating system. Program data 124 includes instructions, and in computing device 100 according to the present invention, program data 124 contains instructions for performing program debugging method 200.
The computing device 100 also includes a storage device 132, the storage device 132 including removable storage 136 and non-removable storage 138, the removable storage 136 and the non-removable storage 138 each connected to the storage interface bus 134. In the present invention, the data related to each event occurring during the program execution process and the time information indicating the occurrence of each event may be stored in the storage device 132, and the operating system 120 is adapted to manage the storage device 132. The storage device 132 may be a magnetic disk.
Computing device 100 may also include an interface bus 140 that facilitates communication from various interface devices (e.g., output devices 142, peripheral interfaces 144, and communication devices 146) to the basic configuration 102 via the bus/interface controller 130. The example output device 142 includes a graphics processing unit 148 and an audio processing unit 150. They may be configured to facilitate communication with various external devices, such as a display or speakers, via one or more a/V ports 152. Example peripheral interfaces 144 may include a serial interface controller 154 and a parallel interface controller 156, which may be configured to facilitate communication with external devices such as input devices (e.g., keyboard, mouse, pen, voice input device, touch input device) or other peripherals (e.g., printer, scanner, etc.) via one or more I/O ports 158. An example communication device 146 may include a network controller 160, which may be arranged to facilitate communications with one or more other computing devices 162 over a network communication link via one or more communication ports 164.
A network communication link may be one example of a communication medium. Communication media may typically be embodied by computer readable instructions, data structures, program modules, and may include any information delivery media, such as carrier waves or other transport mechanisms, in a modulated data signal. A "modulated data signal" may be a signal that has one or more of its data set or its changes made in such a manner as to encode information in the signal. By way of non-limiting example, communication media may include wired media such as a wired network or private-wired network, and various wireless media such as acoustic, Radio Frequency (RF), microwave, Infrared (IR), or other wireless media. The term computer readable media as used herein may include both storage media and communication media.
Computing device 100 may be implemented as a server, such as a file server, a database server, an application server, a WEB server, etc., or as part of a small-form factor portable (or mobile) electronic device, such as a cellular telephone, a Personal Digital Assistant (PDA), a personal media player device, a wireless WEB-watch device, a personal headset device, an application specific device, or a hybrid device that include any of the above functions. Computing device 100 may also be implemented as a personal computer including both desktop and notebook computer configurations. In some embodiments, the operating system 120 of the computing device 100 is configured to perform a message processing method 200 and 300 in accordance with the present invention.
Fig. 2 shows a flow diagram of a message processing method 200 according to one embodiment of the invention. The method 200 is suitable for execution in a computing device 100, such as the computing device 100 described above. As shown in fig. 2, the message processing method 200 begins at step S210. In step S210, a notification message is generated in response to a user operation. For example, in a mail application, a notification message for deleting a mail is generated in response to an operation of deleting the mail at a mail list interface (function module) by a user. And then, sending the generated notification message to a message queue, consuming the notification message in the message queue, and judging the type of the notification message. The notification message type may be defined according to an application program, which is not limited in the present invention, and may be defined according to an actual situation. For example, in a mail application, notification message types as listed in Table 1 may be included.
TABLE 1
Message name Message class Description of the invention
Mail arrival messageMailArrived The mail receiving module will create and send the notice message after receiving the new mail
Mail selection messageMailSeleted The notification message is created and sent when the mail is selected in the mail list interface
Mail delivery messageMailSend The mail content interface will create and send the notification message after sending the new mail
Mail deletion messageMailDelete When the user deletes a certain mail in the mail list interface by the right key, the notification message is created and sent
Account creation messageAccountCreate The account list interface sends this notification message when the user creates a new account
Account deletion messageAccountDelete Delete Account interface will send this message when the user deletes an account
As shown in Table 1, the notification message type includes one or more of mail arrival, mail selection, mail sending, mail deletion, account creation and account deletion, the mail function module includes one or more of mail receiving module, mail list interface, mail content interface, account list interface and account deletion interface, that is, the watcher includes one or more of mail receiving module, mail list interface, mail content interface, account list interface and account deletion interface
Next, in step S220, a watcher queue corresponding to the message type of the generated notification message is searched. Wherein each notification message type corresponds to two watcher queues. In one embodiment of the present invention, the over-member variable names distinguish two observer queues, for example, the over-member variable names of one notification message type corresponding to the two observer queues are first and second, respectively, so as to distinguish the two observer queues.
Taking the notification message types and the function modules in the email application shown in table 1 as examples, when a user deletes an account in an account deletion interface, the account deletion notification message is sent, and if the email function module inherited from the account deletion notification message includes an email list interface, an email content interface, and an account list interface, each of two watcher queues corresponding to the account deletion notification message may include the email list interface, the email content interface, and the account list interface, or one of the two watcher queues includes the email list interface and the email content interface, and the other watcher queue includes the account list interface. The present invention is not limited thereto, and the allocation manner of allocating the watcher to the watcher queue in the prior art is within the protection scope of the present invention.
In one embodiment, one type of notification message is implemented for both watcher queues by modifying the data structure. For example, the data structure of a type of notification message corresponding to a user watcher queue is map < msg, list < object >, where map is a key-value pair container, msg is a message type, and list is a watcher queue. As shown in fig. 3a, the map includes a plurality of key value pairs, in each key value pair, the notification message type is a key of the key value pair, that is, msg is a key of the key value pair, and one observer queue corresponding to the notification message type is a key value of the key value pair, that is, a queue behind msg is a key value of the key value pair.
In the invention, the data structure of one type of notification message corresponding to two observer queues is map < msg, pair < list < observer > where map is a key value pair container, msg is the notification message type, pair is an observer queue pair, that is, each pair corresponds to two lists, and list is the observer queue. As shown in fig. 3b, the map includes a plurality of key value pairs, in each key value pair, the notification message type is a key of the key value pair, that is, msg is a key of the key value pair, and two observer queues corresponding to the notification message type are key values of the key value pair, that is, first and second observer queues after msg are key values of the key value pair.
Thereafter, in step S230, one of the found watcher queues is accessed, and the notification message is processed with the watchers in the watcher queue. Specifically, one of the found observer queues is accessed, an observer registered to the function module is found therefrom, and the notification message is processed by the observer registered to the function module. And in step S240, it is determined whether a new observer is generated in the process of processing the notification message, if so, step S250 is executed to add the new observer to another searched observer queue that is not currently accessed, and if not, step S230 is continuously executed.
In the above method, two observer queues are accessed sequentially, and the order is not changed, for example, first observer queue is accessed and then second observer queue is accessed. If a new observer is generated when an observer in the first observer queue processes the notification message, according to the access sequence of the observer queue, the new observer is added into the second observer queue, the new observer is not activated when the first observer queue is traversed, the new observer is activated when the second observer queue is continuously traversed, and the new observer processes the notification message through the new observer, otherwise, the new observer queue and the second observer queue are the same. It can be seen that the new watcher generated in the above manner is activated and processes the notification message in one traversal of the watcher queue, in this case, in order to further improve the stability of the watcher queue, after the new watcher is added to the watcher queue, in step S260, a flag bit is set and reset for the new watcher.
Next, in step S270, a flag bit of the new observer is set, where the flag bit is 1 when the set flag bit is set, and the flag bit is 0 when the reset flag bit is set, and an observer with the flag bit set may be skipped in the process of accessing one of the searched observer queues, that is, the new observer generated in the process of traversing one observer queue may not be activated, that is, the new observer generated in the process of traversing one observer queue may not process the notification message, so that the currently accessed observer queue is the same as before, and thus in the process of processing the notification message by the observer, the stability of the observer queue is further improved, the crash of the application program is not caused, and the stable operation of the application program is further ensured.
In order to process the notification message by the new observer in the next traversal of the observer queue where the new observer is located, after the traversal of the observer queue is completed for one time, in step S280, it is determined whether a new notification message arrives at the message queue, if yes, step S290 is performed, an observer queue corresponding to the message type of the notification message is searched, and the flag bit of the observer in the searched observer queue is reset, where an observer with the reset flag bit is accessed in the process of accessing one of the searched observer queues. If not, go to step S280.
By the method, when a new observer is generated in the process of processing the notification message, the accessed observer queue is staggered, the new observer is added into the other observer queue of the two observer queues, and the notification message cannot be processed by the generated new observer in the process of one traversal, so that the sizes of the two observer queues can be kept unchanged even if the new observer is generated in the process of one traversal, the stability of the observer queues is ensured, and therefore when a user operates a certain function module of the application program, the application program cannot be crashed, and the stable operation of the application program is ensured.
In the process of processing the notification message by the watcher, the situations of generating a new watcher and deleting an existing watcher also occur, which can cause the queue of the watcher being accessed to be changed, so that the queue of the watcher is not stable any more, and the application program is crashed. Thus, to address the above-described issues, FIG. 3 illustrates a flow diagram of a message processing method 300 according to another embodiment of the invention, the method 300 also being suitable for execution in a computing device 100 (e.g., the computing device 100 described above). As shown in fig. 3, the message processing method 300 starts at step S301, and in step S301, in response to a user operation, a notification message is generated, and then in step S302, a watcher queue corresponding to a message type of the generated notification message is searched, wherein each notification message type also corresponds to two watcher queues.
Then, in step S303, it is determined whether a request to delete an observer is generated during processing of the notification message by the observer, if so, step S304 is performed to determine whether the observer to be deleted is in the observer queue for processing the notification message, and if not, step S303 is performed. If the to-be-deleted watcher is in the watcher queue for processing the notification message, step S305 is executed to set the node of the to-be-deleted watcher to null, that is, the to-be-deleted watcher is logically deleted without releasing the memory resource. If the to-be-deleted observer is not in the observer queue processing the notification message, step S306 is executed to delete the to-be-deleted observer, that is, the to-be-deleted observer is physically deleted, and the memory resource is released.
Subsequently, in step S307, it is determined whether a new observer is generated in the process of processing the notification message, if so, step S308 is executed, another searched observer queue that is not currently accessed is determined according to the member variable identifier of the observer queue, and if not, step S303 is executed. The invention presets member variable identifiers which are set to be proper values when the two observer queues are traversed respectively. For example, when traversing the first observer queue, the member variable flag is set to 1, when traversing the second observer queue, the member variable flag is set to 2, and after traversing the two observer queues, the member variable flag is set to 3. The invention does not limit the specific setting of the member variable identification, and the member variable configuration modes of the observer queue which can be accessed currently are within the protection scope of the invention.
For example, a new watcher is generated in the process of processing the notification message, if the member variable identifier of the watcher queue is 1, it indicates that the first watcher queue is being traversed, and at this time, it is determined that another found watcher queue that is not currently accessed is a second watcher queue. If the member variable identifier of the observer queue is 2, it indicates that the second observer queue is being traversed, and at this time, it is determined that another found observer queue that is not currently accessed is a first observer queue. And if the member variable mark of the observer queue is 3, the traversal is completed for the first observer queue and the second observer queue.
Continuing to execute step S309, determining whether there is an observer with an empty node in another searched observer queue that is not visited, if yes, executing step S310, replacing the observer with an empty node with a new observer, if not, executing step S311, and adding the new observer into another searched observer queue that is not visited. For example, the observer queue with the member variable name first found is being accessed, at this time, the observer queue with the member variable name second found is not accessed, then, it is determined whether an observer with an empty node exists in the observer queue with the member variable name second found, if yes, the observer with the empty node is replaced with a new observer, and if not, the new observer is added into the observer queue with the member variable name second found.
Next, in step S312, a flag bit is set for the new observer, and the flag bit of the new observer is set, so that an observer with the flag bit set may be skipped in the process of accessing one of the searched observer queues, that is, the new observer generated in the process of traversing one observer queue may not be activated, that is, the new observer generated in the process of traversing one observer queue may not process the notification message, so that the currently accessed observer queue is the same as the previous one, and thus, in the process of processing the notification message by the observer, the stability of the observer queue may be further improved, the application may not be crashed, and thus, the stable operation of the application may be further ensured.
In order to enable the new observer to process the notification message in the process of traversing the observer queue where the new observer is located next time, after the observer queue is traversed for one time, in step S313, it is determined whether a new notification message arrives at the message queue, if yes, step S314 is executed to search for an observer queue corresponding to the message type of the notification message, and reset the observer flag bit in the searched observer queue, where an observer with the reset flag bit is accessed in the process of accessing one of the searched observer queues. If not, step S313 is executed.
By the method, when a new observer is generated, the size of the observer queue is not changed, the logically deleted observer can be replaced by the new observer, the memory resource occupied by the logically deleted observer is reused, the new observer does not need to be additionally allocated with the memory resource, the occupation of the memory resource is reduced, and the utilization rate of the memory resource is improved.
In order to better understand the message processing method of the present invention, the whole process of the message processing method of the present invention will be described below by an example.
Assuming that in the email application program, a user performs an account deletion operation on an account deletion interface, at this time, an account deletion notification message is generated, the account deletion notification message is sent to a message queue, an email function module having an inheritance relationship with the account deletion interface includes an email list interface, an email content interface and an account list interface, and two observer queues corresponding to the account deletion notification message each include three observers, namely an email list interface, an email content interface and an account list interface. Wherein, the meaning of existence of inheritance relationship is: when the account deleting interface is operated, the three mail function modules of the mail list interface, the mail content interface and the account list interface execute corresponding operations.
When a user deletes an account on an account deletion interface, an account deletion notification message is sent to a message queue, messages in the message queue are consumed, two observer queues corresponding to the account deletion notification message are searched, the searched observer queue with the member variable name of first is accessed, and the account deletion notification message is processed by using observers (a mail list interface, a mail content interface and an account list interface) in the observer queue with the member variable name of first. And judging whether a request for deleting the observer is generated in the process of processing the account deletion notification message, if so, continuously judging whether the observer to be deleted is in an observer queue with a member variable name of first, and if not, repeatedly judging whether the request for deleting the observer is generated in the process of processing the account deletion notification message. If the observer to be deleted is in the observer queue with the member variable name of first, the observer to be deleted is logically deleted without releasing the memory resource, and if the observer to be deleted is not in the observer queue with the member variable name of first, the observer to be deleted is physically deleted and the memory resource is released.
And then judging whether a new observer is generated in the process of processing the account deletion notification message, if so, determining that the observer queue with the searched member variable name second is not accessed because the observer queue with the searched member variable name first is accessed, and if not, repeatedly judging whether a new observer is generated in the process of processing the account deletion notification message. And then judging whether the logic deleted observer exists in the searched observer queue with the member variable name of second, if so, replacing the logic deleted observer with a new observer, and if not, adding the new observer into the searched observer queue with the member variable name of second.
Subsequently, a flag bit is set for the new watcher, and the flag bit is set, so that the new watcher is skipped when the watcher queue of second is traversed later. And then when a notification message of a new mail application program reaches the message queue, searching two observer queues corresponding to the notification message type of the mail application program, and resetting all observer flag bits in the two searched observer queues (at the moment, the previously added new observer flag bit is also reset), so that when a new notification message arrives, the notification message can be processed by a new observer.
By the method, when a new observer and a deleted observer are generated, the size of the observer queue is not changed, the logically deleted observer can be replaced by the new observer, the memory resource occupied by the logically deleted observer can be reused, the new observer does not need to be additionally allocated with the memory resource, the occupation of the memory resource is reduced, and the utilization rate of the memory resource is improved.
The various techniques described herein may be implemented in connection with hardware or software or, alternatively, with a combination of both. Thus, the methods and apparatus of the present invention, or certain aspects or portions thereof, may take the form of program code (i.e., instructions) embodied in tangible media, such as removable hard drives, U.S. disks, floppy disks, CD-ROMs, or any other machine-readable storage medium, wherein, when the program is loaded into and executed by a machine, such as a computer, the machine becomes an apparatus for practicing the invention.
In the case of program code execution on programmable computers, the computing device will generally include a processor, a storage medium readable by the processor (including volatile and non-volatile memory and/or storage elements), at least one input device, and at least one output device. Wherein the memory is configured to store program code; the processor is configured to perform the message processing method of the present invention according to instructions in the program code stored in the memory.
By way of example, and not limitation, readable media may comprise readable storage media and communication media. Readable storage media store information such as computer readable instructions, data structures, program modules or other data. Communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media. Combinations of any of the above are also included within the scope of readable media.
In the description provided herein, algorithms and displays are not inherently related to any particular computer, virtual system, or other apparatus. Various general purpose systems may also be used with examples of this invention. The required structure for constructing such a system will be apparent from the description above. Moreover, the present invention is not directed to any particular programming language. It is appreciated that a variety of programming languages may be used to implement the teachings of the present invention as described herein, and any descriptions of specific languages are provided above to disclose the best mode of the invention.
In the description provided herein, numerous specific details are set forth. It is understood, however, that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be interpreted as reflecting an intention that: that the invention as claimed requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of this invention.
Those skilled in the art will appreciate that the modules or units or components of the devices in the examples disclosed herein may be arranged in a device as described in this embodiment or alternatively may be located in one or more devices different from the devices in this example. The modules in the foregoing examples may be combined into one module or may be further divided into multiple sub-modules.
Those skilled in the art will appreciate that the modules in the device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and furthermore they may be divided into a plurality of sub-modules or sub-units or sub-components. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or elements are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments described herein include some features included in other embodiments, rather than other features, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments. For example, in the following claims, any of the claimed embodiments may be used in any combination.
Furthermore, some of the described embodiments are described herein as a method or combination of method elements that can be performed by a processor of a computer system or by other means of performing the described functions. A processor having the necessary instructions for carrying out the method or method elements thus forms a means for carrying out the method or method elements. Further, the elements of the apparatus embodiments described herein are examples of the following apparatus: the apparatus is used to implement the functions performed by the elements for the purpose of carrying out the invention.
As used herein, unless otherwise specified the use of the ordinal adjectives "first", "second", "third", etc., to describe a common object, merely indicate that different instances of like objects are being referred to, and are not intended to imply that the objects so described must be in a given sequence, either temporally, spatially, in ranking, or in any other manner.
While the invention has been described with respect to a limited number of embodiments, those skilled in the art, having benefit of this description, will appreciate that other embodiments can be devised which do not depart from the scope of the invention as described herein. Furthermore, it should be noted that the language used in the specification has been principally selected for readability and instructional purposes, and may not have been selected to delineate or circumscribe the inventive subject matter. Accordingly, many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the appended claims. The present invention has been disclosed in an illustrative rather than a restrictive sense, and the scope of the present invention is defined by the appended claims.

Claims (10)

1. A message processing method adapted to be executed in a computing device, the method comprising the steps of:
generating a notification message in response to a user operation;
searching for watcher queues corresponding to message types of the generated notification messages, wherein each type of notification message corresponds to two watcher queues;
accessing one of the found observer queues and processing the notification message by using the observers in the observer queue;
and judging whether a new observer is generated in the process of processing the notification message, if so, adding the new observer into another searched observer queue which is not accessed currently, and if not, accessing one of the searched observer queues and processing the notification message by using the observers in the observer queues.
2. The method of claim 1, further comprising the steps of:
judging whether a request for deleting the observer is generated in the process of processing the notification message by using the observer, if so, judging whether the observer to be deleted is in an observer queue for processing the notification message, and if not, executing a step of judging whether the request for deleting the observer is generated in the process of processing the notification message by using the observer;
wherein the step of determining whether the watcher to be deleted is in the watcher queue for handling notification messages comprises:
and judging whether the observer to be deleted is in an observer queue for processing the notification message, if so, setting the node of the observer to be deleted to be empty, and if not, deleting the observer to be deleted.
3. The method as claimed in claim 2, wherein the step of determining whether a new watcher is generated in the process of processing the notification message, and if so, adding the new watcher to another found watcher queue that is not currently accessed comprises:
judging whether a new observer is generated in the process of processing the notification message, if so, determining another searched observer queue which is not accessed currently according to the member variable identifier of the observer queue, and if not, executing the step of judging whether a new observer is generated in the process of processing the notification message, wherein the observer queue accessed currently is distinguished through the member variable identifier;
and judging whether an observer with an empty node exists in the other searched observer queue which is not accessed, if so, replacing the observer with the empty node with a new observer, and if not, adding the new observer into the other searched observer queue which is not accessed.
4. The method of claim 1, wherein the generating a notification message in response to a user action comprises:
generating a notification message in response to the operation of the functional module by the user;
wherein the step of accessing one of the found watcher queues and processing the notification message with the watchers in the watcher queue comprises:
accessing one of the searched observer queues to search for an observer registered to the functional module;
processing the notification message by the found watcher registered to the functional module.
5. The method of claim 4, further comprising the steps of:
setting a flag bit for the new observer;
and setting the set flag bit, wherein the watchers with the set flag bit are skipped in the process of accessing the found one of the watcher queues.
6. The method of any of claims 1 to 5, wherein, when generating a notification message, the generated notification message is further saved to a message queue, the method further comprising the steps of:
and judging whether a new notification message reaches the message queue, if so, searching the observer queue corresponding to the message type of the notification message, and resetting the observer flag bit in the searched observer queue, wherein an observer with the reset flag bit is accessed in the process of accessing one of the searched observer queues.
7. The method of claim 6, wherein two watcher queues corresponding to notification message types including one or more of mail arrival, mail selection, mail sending, mail deletion, account creation, and account deletion are distinguished according to a member variable name of the watcher.
8. A method of processing a message in a mail system, wherein the message is a message in the mail system, the method comprising the steps of:
responding to the operation of a user on each mail function module in the mail system, and generating a mail notification message;
searching for observer queues corresponding to message types of the generated mail notification messages, wherein each type of notification message corresponds to two observer queues;
accessing one of the found observer queues, and processing the mail notification message by using the observers in the observer queues;
and judging whether a new observer is generated in the process of processing the mail notification message, if so, adding the new observer into another searched observer queue which is not accessed currently, and if not, executing the step of accessing one of the searched observer queues and processing the mail notification message by using the observers in the observer queues.
9. A computing device, comprising:
at least one processor; and
a memory storing program instructions, wherein the program instructions are configured to be adapted to be executed by the at least one processor, the program instructions comprising instructions for performing the method of any of claims 1-8.
10. A readable storage medium storing program instructions that, when read and executed by a computing device, cause the computing device to perform the method of any of claims 1-8.
CN202110323157.8A 2021-03-26 2021-03-26 Message processing method, computing device and storage medium Active CN112711490B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202110624782.6A CN113312189A (en) 2021-03-26 2021-03-26 Message processing method, computing device and storage medium
CN202110323157.8A CN112711490B (en) 2021-03-26 2021-03-26 Message processing method, computing device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110323157.8A CN112711490B (en) 2021-03-26 2021-03-26 Message processing method, computing device and storage medium

Related Child Applications (1)

Application Number Title Priority Date Filing Date
CN202110624782.6A Division CN113312189A (en) 2021-03-26 2021-03-26 Message processing method, computing device and storage medium

Publications (2)

Publication Number Publication Date
CN112711490A true CN112711490A (en) 2021-04-27
CN112711490B CN112711490B (en) 2021-07-16

Family

ID=75550301

Family Applications (2)

Application Number Title Priority Date Filing Date
CN202110624782.6A Pending CN113312189A (en) 2021-03-26 2021-03-26 Message processing method, computing device and storage medium
CN202110323157.8A Active CN112711490B (en) 2021-03-26 2021-03-26 Message processing method, computing device and storage medium

Family Applications Before (1)

Application Number Title Priority Date Filing Date
CN202110624782.6A Pending CN113312189A (en) 2021-03-26 2021-03-26 Message processing method, computing device and storage medium

Country Status (1)

Country Link
CN (2) CN113312189A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113312189A (en) * 2021-03-26 2021-08-27 统信软件技术有限公司 Message processing method, computing device and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106850402A (en) * 2017-01-16 2017-06-13 腾讯科技(深圳)有限公司 The transmission method and device of message
CN107450971A (en) * 2017-06-29 2017-12-08 北京五八信息技术有限公司 Task processing method and device
WO2018199817A1 (en) * 2017-04-24 2018-11-01 Telefonaktiebolaget Lm Ericsson (Publ) Message queue performance monitoring
CN108965587A (en) * 2018-06-26 2018-12-07 恒生电子股份有限公司 A kind of message prompt method, device and equipment
CN110213371A (en) * 2019-05-31 2019-09-06 深圳前海微众银行股份有限公司 Information consumption method, apparatus, equipment and computer storage medium
CN111694674A (en) * 2019-03-13 2020-09-22 北京字节跳动网络技术有限公司 Message distribution processing method, device, equipment and storage medium

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8464275B2 (en) * 2006-05-10 2013-06-11 Oracle International Corporation Method of using a plurality of subscriber types in managing a message queue of a database management system
US9436532B1 (en) * 2011-12-20 2016-09-06 Emc Corporation Method and system for implementing independent message queues by specific applications
CN108153596A (en) * 2017-12-15 2018-06-12 珠海金山网络游戏科技有限公司 A kind of message treatment method and device based on lock-free queue
CN110032459B (en) * 2019-04-22 2022-05-03 深圳乐信软件技术有限公司 Message queue configuration method and device, computer equipment and storage medium
CN111309494A (en) * 2019-12-09 2020-06-19 上海金融期货信息技术有限公司 Multithreading event processing assembly
CN112099895A (en) * 2020-09-28 2020-12-18 广州华多网络科技有限公司 Interface notification message scheduling method, device, equipment and storage medium
CN113312189A (en) * 2021-03-26 2021-08-27 统信软件技术有限公司 Message processing method, computing device and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106850402A (en) * 2017-01-16 2017-06-13 腾讯科技(深圳)有限公司 The transmission method and device of message
WO2018199817A1 (en) * 2017-04-24 2018-11-01 Telefonaktiebolaget Lm Ericsson (Publ) Message queue performance monitoring
CN107450971A (en) * 2017-06-29 2017-12-08 北京五八信息技术有限公司 Task processing method and device
CN108965587A (en) * 2018-06-26 2018-12-07 恒生电子股份有限公司 A kind of message prompt method, device and equipment
CN111694674A (en) * 2019-03-13 2020-09-22 北京字节跳动网络技术有限公司 Message distribution processing method, device, equipment and storage medium
CN110213371A (en) * 2019-05-31 2019-09-06 深圳前海微众银行股份有限公司 Information consumption method, apparatus, equipment and computer storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113312189A (en) * 2021-03-26 2021-08-27 统信软件技术有限公司 Message processing method, computing device and storage medium

Also Published As

Publication number Publication date
CN113312189A (en) 2021-08-27
CN112711490B (en) 2021-07-16

Similar Documents

Publication Publication Date Title
CN111651464B (en) Data processing method, system and computing device
CN108287708B (en) Data processing method and device, server and computer readable storage medium
CN111104448A (en) Method and device for exporting large-data-volume Excel file, computer equipment and storage medium
JP6266588B2 (en) Synchronizing local and remote data
US9038093B1 (en) Retrieving service request messages from a message queue maintained by a messaging middleware tool based on the origination time of the service request message
CN111563024A (en) Method and device for monitoring container process on host machine and computing equipment
CN114625545A (en) Process lock holding detection method, electronic device and readable medium thereof
CN112711490B (en) Message processing method, computing device and storage medium
CN113139195A (en) Data encryption method and computing device
CN114461404B (en) Process migration method, computing device and readable storage medium
CN116192956A (en) Cache data updating method, system, computing device and storage medium
CN108228842B (en) Docker mirror image library file storage method, terminal, device and storage medium
CN108733536B (en) Monitoring management system and method
CN117130979A (en) Service resource migration method and device and electronic equipment
CN112000482B (en) Memory management method and device, electronic equipment and storage medium
CN110764933B (en) Message processing method, device and system and computing equipment
CN114900566A (en) Data communication method, device, electronic equipment and medium
CN108874560B (en) Method and communication device for communication
CN110716814B (en) Performance optimization method and device for inter-process large-data-volume communication
CN113342270A (en) Volume unloading method and device and electronic equipment
CN113485761A (en) Processing method, device, equipment and medium for resource access request
CN112181516A (en) Application software execution method and computing device
CN113031908B (en) Ordered data processing method and computing device
CN113194127B (en) Data storage method, data transmission method and computing equipment
WO2022156099A1 (en) Host upgrade method and apparatus, and electronic device and storage medium

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