A message processing method, computing device and storage medium

By assigning two observer queues to each notification message type and adding them to the unvisited queue when a new observer is generated, the observer queue instability problem of the application when processing messages is solved, and the application is stable running.

CN113312189BActive Publication Date: 2025-04-08UNIONTECH SOFTWARE TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202110624782.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-26
Publication Date
2025-04-08
Estimated Expiration
2041-03-26

AI Technical Summary

Technical Problem

In the prior art, applications are prone to instability in the observer queue when processing messages, resulting in the application crash.

Method used

A message processing method is provided to maintain the stability of the queue by assigning two observer queues to each notification message type, ensuring that new observers are added to another queue that is not accessed when they are generated.

Benefits of technology

By staggering the joining of new observers, the instability of the observer queue when processing notification messages is avoided, and the stable operation of the application is ensured.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113312189B_ABST
    Figure CN113312189B_ABST
Patent Text Reader

Abstract

The present invention discloses a message processing method, a computing device and a storage medium. The method generates a notification message in response to a user operation; searches for an observer queue corresponding to the message type of the generated notification message, accesses one of the found observer queues, and uses the observer in the observer queue to process the notification message; determines whether a new observer is generated in the process of processing the notification message, and if so, adds the new observer to another currently found observer queue that is not accessed; if not, continues to execute the step of determining whether a new observer is generated in the process of processing the notification message. Through the above method, when a new observer is generated, the observer queue being accessed is staggered, and the new observation is saved in another observer queue corresponding to the notification message type, thereby ensuring the stability of the observer queue in the process of processing the notification message.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This invention is a divisional application of invention patent 2021103231578 applied for on March 26, 2021. Technical Field

[0002] The present invention relates to the technical field of message processing, and in particular to a message processing system, a computing device and a storage medium. Background Art

[0003] An application is a collection of various programming languages ​​that users can use, as well as programs compiled in various programming languages. Applications can meet the application needs of different fields and different problems. Therefore, the use of applications is becoming more and more widespread. The design and development of an application includes multiple functional modules, and each functional module will notify each other of messages.

[0004] At present, most of them design a message notification class in the middle layer of the application. This class maintains two types of queues, one is the notification message queue, and the other is multiple observer queues. Among them, the notification message queue includes multiple types of notification messages, and the observer queue consumes the notification messages in the message queue. One notification message type corresponds to one observer queue. The functional module inherited from the notification message can register itself in the observer queue of the corresponding type of notification message, so as to receive notification messages sent by other functional modules or this functional module. When a notification message is detected in the message queue, the observer queue corresponding to the notification message of this type is traversed, and the processing function of the observer in the observer queue for this type of notification message is called in turn to complete the processing of the notification message. However, in the process of the observer processing the notification message, the observer queue is often unstable, which can easily cause the application to crash.

[0005] Therefore, a message processing method is needed to solve the problem of instability of the application program when processing messages in the above technical solution. Summary of the invention

[0006] To this end, the present invention provides a message processing method to try to solve or at least alleviate the above problems.

[0007] According to one aspect of the present invention, there is provided a message processing method suitable for execution in a computing device, the method comprising the steps of:

[0008] In response to a user operation, generating a notification message;

[0009] Find an observer queue corresponding to the message type of the generated notification message, wherein each type of notification message corresponds to two observer queues;

[0010] Accessing one of the found observer queues and processing the notification message using an observer in the observer queue;

[0011] Determine whether a new observer is generated in the process of processing the notification message. If so, add the new observer to another found observer queue that is not currently accessed. If not, execute the step of accessing one of the found observer queues and using the observer in the observer queue to process the notification message.

[0012] Optionally, the method further comprises the steps of:

[0013] Determine whether a request to delete the observer is generated in the process of using the observer to process the notification message, if so, determine whether the observer to be deleted is in the observer queue for processing the notification message, if not, execute the step of determining whether a request to delete the observer is generated in the process of using the observer to process the notification message;

[0014] The step of determining whether the observer to be deleted is in the observer queue for processing the notification message includes:

[0015] Determine whether the observer to be deleted is in the observer queue that processes the notification message. If so, set the node of the observer to be deleted to empty. If not, delete the observer to be deleted.

[0016] Optionally, the step of determining whether a new observer is generated in the process of processing the notification message, and if so, adding the new observer to another currently unaccessed observer queue comprises:

[0017] Determine whether a new observer is generated in the process of processing the notification message, and if so, determine another observer queue that is not currently accessed according to the member variable identifier of the observer queue, and if not, perform the step of determining whether a new observer is generated in the process of processing the notification message, wherein the currently accessed observer queue is distinguished by the member variable identifier;

[0018] Determine whether there is an observer with an empty node in the other observer queue that has not been visited. If so, replace the observer with an empty node with a new observer. If not, add the new observer to the other observer queue that has not been visited.

[0019] Optionally, the step of generating a notification message in response to a user operation includes:

[0020] In response to a user's operation on a functional module, generating a notification message;

[0021] The step of processing the notification message by an observer in one of the found observer queues includes:

[0022] Access one of the found observer queues to search for an observer registered to the functional module;

[0023] The notification message is processed by the found observer registered with the functional module.

[0024] Optionally, the method further comprises the steps of:

[0025] Setting a flag for the new observer;

[0026] The flag is set, wherein the observer with the flag set is skipped during access to one of the observer queues that has been found.

[0027] Optionally, the method further comprises the steps of:

[0028] Determine whether a new notification message arrives at the message queue. If so, search for the observer queue corresponding to the message type of the notification message, and reset the observer flag in the found observer queue, wherein the observer with the reset flag will be accessed in the process of accessing one of the found observer queues.

[0029] Optionally, two observer queues corresponding to the notification message types are distinguished according to the member variable names of the observers.

[0030] Optionally, the notification message type includes one or more of email arrival, email selection, email sending, email deletion, account creation and account deletion.

[0031] According to another aspect of the present invention, a method for processing a message in an email system is provided, wherein the message is a message in the email system, and the method comprises the steps of:

[0032] In response to the user's operation on each mail function module in the mail system, generate a mail notification message;

[0033] Find an observer queue corresponding to the message type of the generated email notification message, wherein each type of notification message corresponds to two observer queues;

[0034] Accessing one of the found observer queues, and using the observer in the observer queue to process the email notification message;

[0035] Determine whether a new observer is generated in the process of processing the email notification message. If so, add the new observer to another observer queue that has not been accessed. If not, execute the step of accessing one of the observer queues that have been found and use the observer in the observer queue to process the email notification message.

[0036] According to another aspect of the present invention, a computing device is provided, comprising: at least one processor; and a memory storing program instructions, wherein the program instructions are configured to be suitable for being executed by the at least one processor, and the program instructions include instructions for executing the method as described above.

[0037] According to another aspect of the present invention, a readable storage medium storing program instructions is provided. When the program instructions are read and executed by a computing device, the computing device executes the above method.

[0038] According to the technical solution of the present invention, a message processing method is provided, in which one notification message type corresponds to two observer queues, so that when a new observer is generated, the observer queue being accessed is staggered, and the new observation is saved in another observer queue corresponding to the notification message type, thereby ensuring the stability of the observer queue in the process of processing the notification message. Specifically, in response to user operation, a notification message is generated, two observer queues corresponding to the message type of the generated notification message are searched, one of the found observer queues is accessed, and the notification message is processed using the observers in the observer queues, and it is determined whether a new observer is generated in the process of processing the notification message. If so, the new observer is added to another found observer queue that is not currently accessed. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] To achieve the above and related purposes, certain illustrative aspects are described herein in conjunction with the following description and accompanying drawings, which indicate various ways in which the principles disclosed herein can be practiced, and all aspects and their equivalents are intended to fall within the scope of the claimed subject matter. The above and other purposes, features and advantages of the present disclosure will become more apparent by reading the following detailed description in conjunction with the accompanying drawings. Throughout the present disclosure, the same reference numerals generally refer to the same parts or elements.

[0040] Figure 1 A schematic diagram of a computing device 100 according to one embodiment of the present invention is shown;

[0041] Figure 2 A flowchart of a message processing method 200 according to an embodiment of the present invention is shown;

[0042] Figure 3a-3bA schematic diagram showing an observer queue data structure according to an embodiment of the present invention; and

[0043] Figure 4 A flowchart of a message processing method 300 according to another embodiment of the present invention is shown. DETAILED DESCRIPTION

[0044] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

[0045] The existing technology includes multiple functional modules in the design and development of application programs, and each functional module will notify each other of messages. At present, most of them are designed by designing a message notification class in the middle layer of the application. This class maintains two types of queues, one is the notification message queue, and the other is multiple observer queues. Among them, the notification message queue includes multiple types of notification messages, the observer queue consumes the notification messages of the message queue, and one notification message type corresponds to an observer queue. The functional module inherited from the notification message can register itself in the observer queue of the corresponding type of notification message, so as to receive notification messages sent by other functional modules or this functional module. When a notification message arrives, it traverses an observer queue corresponding to the message type of the notification message, and calls the processing function of the observer in the observer queue for this type of notification message in turn to complete the processing of the notification message. Among them, the observer is a functional module registered in the corresponding type and observer queue. Each functional module is responsible for receiving notification messages sent by other modules or this module, and processing notification messages.

[0046] However, when an observer processes a notification message, it often creates a new observer or deletes an existing observer, causing the observer queue being accessed to change. This makes the observer queue unstable and often causes the application to crash due to invalid observer indexes or pointers when accessing. Moreover, the above process is performed within a thread and cannot be solved by locking.

[0047] 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 queue being accessed is staggered, and the new observation is saved in another observer queue corresponding to the notification message type, thereby ensuring the stability of the observer queue in the process of processing the notification message. Specifically, in response to user operation, a notification message is generated, two observer queues corresponding to the message type of the generated notification message are searched, one of the found observer queues is accessed, and the notification message is processed using the observers in the observer queues, and it is determined whether a new observer is generated in the process of processing the notification message. If so, the new observer is added to another found observer queue that is not currently accessed.

[0048] The message processing method provided by the present invention is executed in a computing device. Figure 1 FIG. 1 is a block diagram of a computing device 100 according to an embodiment of the present invention. Figure 1 As shown, in a basic configuration 102, computing device 100 typically includes system memory 106 and one or more processors 104. A memory bus 108 may be used for communication between processor 104 and system memory 106.

[0049] Depending on the desired configuration, the processor 104 can be any type of processor, including but not limited to: a microprocessor (μP), a microcontroller (μC), a digital information processor (DSP), or any combination thereof. The processor 104 can include one or more levels of cache such as a first-level cache 110 and a second-level cache 112, a processor core 114, and registers 116. An example processor core 114 can include an arithmetic logic unit (ALU), a floating point unit (FPU), a digital signal processing core (DSP core), or any combination thereof. An example memory controller 118 can be used with the processor 104, or in some implementations, the memory controller 118 can be an internal part of the processor 104.

[0050] Depending on the desired configuration, the system memory 106 can 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. The system memory 106 can include an operating system 120, one or more applications 122, and program data 124. In some embodiments, the application 122 can be arranged to operate on the operating system using the program data 124. The program data 124 includes instructions, and in the computing device 100 according to the present invention, the program data 124 includes instructions for executing the message processing methods 200 and 300.

[0051] The computing device 100 further includes a storage device 132, which includes a removable storage 136 and a non-removable storage 138, and both the removable storage 136 and the non-removable storage 138 are connected to the storage interface bus 134. In the present invention, data related to each event occurring during program execution and time information indicating the occurrence of each event can be stored in the storage device 132, and the operating system 120 is suitable for managing the storage device 132. The storage device 132 can be a disk.

[0052] The 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. Example output devices 142 include a graphics processing unit 148 and an audio processing unit 150. They can 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., keyboards, mice, pens, voice input devices, touch input devices) or other peripherals (e.g., printers, scanners, etc.) via one or more I / O ports 158. Example communication devices 146 may include a network controller 160, which may be arranged to facilitate communication with one or more other computing devices 162 via a network communication link via one or more communication ports 164.

[0053] A network communication link can be an example of a communication medium. Communication media can generally be embodied as computer-readable instructions, data structures, program modules in a modulated data signal such as a carrier wave or other transmission mechanism, and can include any information delivery medium. A "modulated data signal" can be a signal in which one or more of its data sets or its changes can be carried out in a manner that encodes information in the signal. As non-limiting examples, communication media can include wired media such as a wired network or a dedicated line network, and various wireless media such as sound, radio frequency (RF), microwave, infrared (IR) or other wireless media. The term computer-readable medium used herein can include both storage media and communication media.

[0054] The computing device 100 can be implemented as a server, such as a file server, a database server, an application server, and a WEB server, etc., and can also be implemented as a part of a small-sized portable (or mobile) electronic device, such as a cellular phone, a personal digital assistant (PDA), a personal media player device, a wireless network browsing device, a personal head-mounted device, an application-specific device, or a hybrid device that can include any of the above functions. The computing device 100 can also be implemented as a personal computer including a desktop computer and a notebook computer configuration. In some embodiments, the operating system 120 of the computing device 100 is configured to execute a message processing method 200 and 300 according to the present invention.

[0055] Figure 2 1 is a flowchart of a message processing method 200 according to an embodiment of the present invention. The method 200 is suitable for being executed in a computing device 100 (such as the aforementioned computing device 100). Figure 2 As shown, the message processing method 200 starts at step S210. In step S210, a notification message is generated in response to a user operation. For example, in an email application, in response to a user's operation of deleting an email in an email list interface (functional module), a notification message of deleting an email is generated. Afterwards, the generated notification message is sent to a message queue, the notification message in the message queue is consumed, and the type of the notification message is determined. Among them, the notification message type can be defined according to the application. Of course, the present invention is not limited to this, and the notification message type can be defined according to actual conditions. For example, in an email application, the notification message types listed in Table 1 can be included.

[0056] Table 1

[0057]

[0058] 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 to say, the observer includes one or more of mail receiving module, mail list interface, mail content interface, account list interface and account deletion interface.

[0059] Next, in step S220, the observer queue corresponding to the message type of the generated notification message is searched. Each notification message type corresponds to two observer queues. In one embodiment of the present invention, the two observer queues are distinguished by the member variable name. For example, the member variable names of the two observer queues corresponding to one notification message type are first and second, respectively, so as to distinguish the two observer queues.

[0060] Taking the notification message types and the functional modules in the mail application shown in Table 1 as an example, when a user deletes an account in the account deletion interface, an account deletion notification message will be sent. If the mail functional module inherited from the account deletion notification message includes a mail list interface, a mail content interface, and an account list interface, then each of the two observer queues corresponding to the account deletion notification message may include a mail list interface, a mail content interface, and an account list interface, or one of the two observer queues includes a mail list interface and a mail content interface, and the other observer queue includes an account list interface. The present invention does not limit this, and the allocation method of allocating observers to observer queues in the prior art is within the protection scope of the present invention.

[0061] In one embodiment, the data structure is modified to realize that one type of notification message corresponds to two observer queues. For example, the data structure of one type of notification message corresponding to one observer queue is map <msg,list<obervor*> *>, where map is a key-value pair container, msg is the message type, and list is the observer queue. Figure 3a As shown, the map includes multiple key-value pairs. In each key-value pair, the notification message type is the key of the key-value pair, that is, msg is the key of the key-value pair, and an observer queue corresponding to the notification message type is the key value of the key-value pair, that is, the queue after msg is the key value of the key-value pair.

[0062] In the present invention, the data structure of one type of notification message corresponding to two observer queues is map <msg,pair<list<obervor*> *list<observor*> *>>, where map is a key-value pair container, msg is the notification message type, and pair is an observer queue pair, that is, each pair corresponds to two lists, and list is the observer queue. Figure 3b As shown, the map includes multiple key-value pairs. In each key-value pair, the notification message type is the key of the key-value pair, that is, msg is the key of the key-value pair, and the two observer queues corresponding to the notification message type are the key values ​​of the key-value pair, that is, the first and second observer queues after msg are the key values ​​of the key-value pair.

[0063] Then in step S230, one of the found observer queues is accessed, and the observer in the observer queue is used to process the notification message. Specifically, one of the found observer queues is accessed, and the observer registered with the functional module is searched therefrom, and the notification message is processed by the observer registered with the functional 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 found observer queue that is not currently accessed. If not, step S230 is continued.

[0064] In the above method, the two observer queues are visited sequentially, and the order will not change. For example, the first observer queue is visited first, and then the second observer queue is visited. If a new observer is generated when the observer in the first observer queue processes a notification message, the new observer will be added to the second observer queue according to the access order of the above observer queues. The new observer will not be activated when traversing the first observer queue. When the second observer queue continues to be traversed, the new observer will be activated and the notification message will be processed by the new observer, and vice versa. It can be seen that the new observer generated by the above method is activated and processes the notification message in the process of traversing the observer queue once. In this case, in order to further improve the stability of the observer queue, after the new observer is added to the observer queue, in step S260, a flag is set for the new observer, where the flag is set or reset.

[0065] Next, in step S270, the flag of the new observer is set, wherein the flag is 1 when set and the flag is 0 when reset. The observer with the flag set will be skipped during the access to one of the found observer queues. That is, the new observer generated during the traversal of the observer queue will not be activated. In other words, the new observer generated during the traversal of the observer queue will not process the notification message, which makes the currently accessed observer queue the same as the previous one. Therefore, in the process of the observer processing the notification message, the stability of the observer queue is further improved, and the application will not crash, thereby further ensuring the stable operation of the application.

[0066] In order for the new observer to be able to process the notification message during the next traversal of the observer queue where the new observer is located, after traversing the observer queue once, in step S280, it is determined whether a new notification message has arrived in the message queue. If so, step S290 is executed to find the observer queue corresponding to the message type of the notification message, and reset the observer flag in the found observer queue, wherein the observer with the reset flag will be accessed during the access to one of the found observer queues. If not, step S280 is executed.

[0067] Through the above method, when a new observer is generated in the process of processing a notification message, the observer queue being accessed is staggered, and the new observer is added to the other observer queue of the two observer queues. In addition, in one traversal process, the notification message will not be processed by the newly generated observer. Therefore, in one traversal process, even if a new observer is generated, the sizes of the two observer queues can remain unchanged, thereby ensuring the stability of the observer queue. Therefore, when the user operates a functional module of the application, it will not cause the application to crash, thereby ensuring the stable operation of the application.

[0068] In the process of observers processing notification messages, new observers may be generated and existing observers may be deleted, which may cause changes in the observer queue being accessed, making the observer queue no longer stable, and causing the application to crash. Therefore, in order to solve the above problems, FIG3 shows a flowchart of a message processing method 300 according to another embodiment of the present invention, and the method 300 is also suitable for execution in a computing device 100 (such as the aforementioned computing device 100). As shown in FIG3, the message processing method 300 begins with step S301. In step S301, a notification message is generated in response to a user operation, and then in step S302, an observer queue corresponding to the message type of the generated notification message is searched, wherein each notification message type also corresponds to two observer queues.

[0069] Then in step S303, determine whether a request to delete the observer is generated in the process of using the observer to process the notification message. If so, execute step S304 to determine whether the observer to be deleted is in the observer queue that processes the notification message. If not, execute step S303. Among them, if the observer to be deleted is in the observer queue that processes the notification message, execute step S305 to set the node of the observer to be deleted to empty, that is, logically delete the observer to be deleted, and do not release memory resources. If the observer to be deleted is not in the observer queue that processes the notification message, execute step S306 to delete the observer to be deleted, that is, physically delete the observer to be deleted and release memory resources.

[0070] Then, 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 to determine another found observer queue that is not currently accessed based on the member variable identifier of the observer queue. If not, step S303 is executed. Among them, the currently accessed observer queue is distinguished by the member variable identifier. The member variable identifier is pre-set in the present invention, and the member variable identifier is set to an appropriate value when traversing the two observer queues respectively. For example, when traversing the first observer queue, the member variable identifier is set to 1, and when traversing the second observer queue, the member variable identifier is set to 2. After traversing the two observer queues, the member variable identifier is set to 3. The present invention does not limit the specific setting of the member variable identifier. As long as the member variable configuration method that can distinguish the currently accessed observer queue is within the protection scope of the present invention.

[0071] For example, when a new observer is generated during the process of processing a notification message, if the member variable of the observer queue is marked as 1, it means that the first observer queue is being traversed, and at this time, another observer queue that has been found and is not currently accessed is determined to be the second observer queue. If the member variable of the observer queue is marked as 2, it means that the second observer queue is being traversed, and at this time, another observer queue that has been found and is not currently accessed is determined to be the first observer queue. If the member variable of the observer queue is marked as 3, it means that the traversal of the first and second observer queues is completed.

[0072] Continue to execute step S309, and determine whether there is an observer with an empty node in another found observer queue that has not been visited. If so, execute step S310 to replace the observer with an empty node with a new observer. If not, execute step S311 to add the new observer to another found observer queue that has not been visited. For example, the observer queue with the member variable name of first that has been found is being accessed, and the observer queue with the member variable name of second that has been found is not visited. Then determine whether there is an observer with an empty node in the observer queue with the member variable name of second that has been found. If so, replace the observer with an empty node with a new observer. If not, add the new observer to the observer queue with the member variable name of second that has been found.

[0073] Next, in step S312, a flag is set for the new observer, and the flag of the new observer is set. In the process of accessing one of the observer queues that has been found, the observer with the flag set will be skipped. That is, the new observer generated in the process of traversing the observer queue once will not be activated. In other words, the new observer generated in the process of traversing the observer queue once will not process the notification message, which makes the currently accessed observer queue the same as the previous one. Therefore, in the process of the observer processing the notification message, the stability of the observer queue is further improved, and the application will not crash, thereby further ensuring the stable operation of the application.

[0074] In order for the new observer to be able to process the notification message during the next traversal of the observer queue where the new observer is located, after traversing the observer queue once, in step S313, it is determined whether a new notification message has arrived in the message queue. If so, step S314 is executed to find the observer queue corresponding to the message type of the notification message, and reset the observer flag in the found observer queue, wherein the observer with the reset flag will be accessed during the access to one of the found observer queues. If not, step S313 is executed.

[0075] Through the above method, while ensuring that the size of the observer queue remains unchanged when a new observer is generated, the logically deleted observer can be replaced with a new observer, thereby reusing the memory resources occupied by the logically deleted observer. At this time, there is no need to allocate additional memory resources for the new observer, thereby reducing the occupation of memory resources and improving the utilization of memory resources.

[0076] In order to better understand the message processing method of the present invention, the entire process of the message processing method of the present invention will be described below by using an example.

[0077] Assume that in the mail application, the user deletes the account in the account deletion interface, and an account deletion notification message is generated. The account deletion notification message is sent to the message queue. The mail function modules that have an inheritance relationship with the account deletion interface include the mail list interface, the mail content interface, and the account list interface, and the two observer queues corresponding to the account deletion notification message include three observers, namely, the mail list interface, the mail content interface, and the account list interface. The existence of an inheritance relationship means that when the account deletion interface is operated, the three mail function modules, namely, the mail list interface, the mail content interface, and the account list interface, will all perform corresponding operations.

[0078] When a user deletes an account in the account deletion interface, an account deletion notification message is sent to the message queue, the messages in the message queue are consumed, the two observer queues corresponding to the account deletion notification message are searched, and the observer queue with the member variable name first that has been found is accessed. The observers in the observer queue with the member variable name first (email list interface, email content interface, and account list interface) are used to process the account deletion notification message. It is also determined whether a request to delete the observer is generated during the processing of the account deletion notification message. If so, it is continued to determine whether the observer to be deleted is in the observer queue with the member variable name first. If a request to delete the observer is not generated during the processing of the account deletion notification message, it is repeatedly determined whether a request to delete the observer is generated during the processing of the account deletion notification message. Among them, if the observer to be deleted is in the observer queue with the member variable name first, the observer to be deleted is logically deleted without releasing memory resources. If the observer to be deleted is not in the observer queue with the member variable name first, the observer to be deleted is physically deleted to release memory resources.

[0079] Next, it is determined whether a new observer is generated in the process of processing the account deletion notification message. If so, since the observer queue with the member variable name first that has been found is being accessed, it is determined that the observer queue with the member variable name second that has been found has not been accessed at this time. If not, it is repeatedly determined whether a new observer is generated in the process of processing the account deletion notification message. Then it is determined whether there is a logically deleted observer in the observer queue with the member variable name second that has been found. If so, the logically deleted observer is replaced with a new observer. If not, the new observer is added to the observer queue with the member variable name second that has been found.

[0080] Then, a flag is set for the new observer, and the flag is set so that the new observer is skipped when the observer queue of second is traversed. When a new notification message from a mail application arrives in the message queue, two observer queues corresponding to the notification message type of the mail application are searched, and all observer flags in the two observer queues that have been found are reset (the flag of the new observer added before is also reset at this time), so that when a new notification message arrives, the notification message can also be processed by the new observer.

[0081] Through the above method, when generating new observers and deleting observers, while ensuring that the size of the observer queue remains unchanged, the logically deleted observers can be replaced with new observers, so as to reuse the memory resources occupied by the logically deleted observers. At this time, there is no need to allocate additional memory resources for the new observers, thereby reducing the occupation of memory resources and improving the utilization rate of memory resources.

[0082] The various techniques described herein may be implemented in combination with hardware or software, or a combination thereof. Thus, the method and apparatus of the present invention, or some aspects or parts of the method and apparatus of the present invention may be in the form of program codes (i.e., instructions) embedded in a tangible medium, such as a removable hard disk, a USB flash drive, a floppy disk, a CD-ROM, or any other machine-readable storage medium, wherein when the program is loaded into a machine such as a computer and executed by the machine, the machine becomes a device for practicing the present invention.

[0083] In the case where the program code is executed on a programmable computer, the computing device generally includes 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. The memory is configured to store the program code; the processor is configured to execute the message processing method of the present invention according to the instructions in the program code stored in the memory.

[0084] By way of example and not limitation, readable media include readable storage media and communication media. Readable storage media stores information such as computer readable instructions, data structures, program modules or other data. Communication media generally embody computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transmission mechanism, and include any information transfer medium. Any combination of the above is also included within the scope of readable media.

[0085] In the description provided herein, algorithms and displays are not inherently related to any particular computer, virtual system or other device. Various general purpose systems can also be used together with the examples of the present invention. According to the above description, it is obvious that the structure required for constructing such systems. In addition, the present invention is not directed to any specific programming language either. It should be understood that various programming languages ​​can be utilized to implement the content of the present invention described herein, and the above description of specific languages ​​is for the purpose of disclosing the best mode of the present invention.

[0086] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.

[0087] Similarly, it should be understood that in order to streamline the present disclosure and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the present invention, the various features of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, this disclosed method should not be interpreted as reflecting the following intention: that the claimed invention requires more features than the features explicitly recited in each claim. More specifically, as reflected in the claims below, inventive aspects lie in less than all the features of the individual embodiments disclosed above. Therefore, the claims that follow the specific embodiment are hereby expressly incorporated into the specific embodiment, with each claim itself serving as a separate embodiment of the present invention.

[0088] 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 the devices described in the embodiment, or alternatively may be located in one or more devices different from the devices in the examples. The modules in the foregoing examples may be combined into one module or may be divided into multiple submodules.

[0089] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and in addition they may be divided into a plurality of submodules or subunits or subcomponents. Except that at least some of such features and / or processes or units are mutually exclusive, all features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed in this manner may be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.

[0090] In addition, those skilled in the art will appreciate that, although some embodiments described herein include certain features included in other embodiments but not other features, the combination of features of different embodiments is meant to be within the scope of the present invention and form different embodiments. For example, in the claims below, any one of the claimed embodiments may be used in any combination.

[0091] In addition, some of the embodiments are described herein as methods or combinations of method elements that can be implemented by a processor of a computer system or by other devices that perform the functions. Therefore, a processor with necessary instructions for implementing the method or method elements forms a device for implementing the method or method elements. In addition, the elements described herein of the device embodiments are examples of devices for implementing the functions performed by the elements for the purpose of implementing the invention.

[0092] As used herein, unless otherwise specified, the use of ordinal numbers "first," "second," "third," etc. to describe common objects merely indicates that different instances of similar objects are involved, and is not intended to imply that the objects so described must have a given order in time, space, order, or in any other manner.

[0093] Although the present invention has been described according to a limited number of embodiments, it will be apparent to those skilled in the art, with the benefit of the above description, that other embodiments may be envisioned within the scope of the invention thus described. In addition, it should be noted that the language used in this specification is selected primarily for readability and teaching purposes, rather than for explaining or defining the subject matter of the present invention. Therefore, many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the appended claims. The disclosure of the present invention is illustrative, not restrictive, with respect to the scope of the present invention, which is defined by the appended claims.

Claims

1. A message processing method, suitable for execution in a computing device, the method comprising the steps of: In response to a user operation, generating a notification message; Searching for an observer queue corresponding to a message type of the generated notification message, wherein each type of notification message corresponds to two observer queues, and the observer queues include one or more of an email receiving module, an email list interface, an email content interface, an account list interface, and an account deletion interface; Accessing one of the found observer queues and processing the notification message using an observer in the observer queue; Determine whether a new observer is generated in the process of processing the notification message. If so, add the new observer to another currently unaccessed observer queue. If not, access one of the currently accessed observer queues and use the observer in the observer queue to process the notification message. Determine whether a request to delete the observer is generated in the process of using the observer to process the notification message. If so, determine whether the observer to be deleted is in the observer queue that processes the notification message. If not, execute the step of determining whether a request to delete the observer is generated in the process of using the observer to process the notification message.

2. The method of claim 1, wherein: The step of determining whether the observer to be deleted is in the observer queue for processing the notification message includes: Determine whether the observer to be deleted is in the observer queue that processes the notification message. If so, set the node of the observer to be deleted to empty. If not, delete the observer to be deleted.

3. The method of claim 2, wherein: The step of determining whether a new observer is generated in the process of processing the notification message, and if so, adding the new observer to another currently unaccessed observer queue that has been found comprises: Determine whether a new observer is generated in the process of processing the notification message, and if so, determine another observer queue that is not currently accessed according to the member variable identifier of the observer queue, and if not, perform the step of determining whether a new observer is generated in the process of processing the notification message, wherein the currently accessed observer queue is distinguished by the member variable identifier; Determine whether there is an observer with an empty node in the other observer queue that has not been visited. If so, replace the observer with an empty node with a new observer. If not, add the new observer to the other observer queue that has not been visited.

4. The method of claim 1, wherein: The step of generating a notification message in response to a user operation includes: In response to a user's operation on a functional module, generating a notification message; The step of accessing one of the found observer queues and using the observer in the observer queue to process the notification message includes: Access one of the found observer queues to search for an observer registered to the functional module; The notification message is processed by the found observer registered with the functional module.

5. The method according to claim 4, further comprising the steps of: Setting a flag for the new observer; Set the new observer flag, where Skip observers with the flag set during access to one of the found observer queues.

6. The method according to any one of claims 1 to 5, further comprising the steps of: Determine whether a new notification message arrives at the message queue. If so, search for the observer queue corresponding to the message type of the notification message and reset the observer flag in the observer queue that has been found. During the access to one of the found observer queues, the observer with the flag reset will be accessed.

7. The method of claim 6, wherein: Two observer queues corresponding to notification message types are distinguished according to the member variable names of the observers, and the notification message types include one or more of mail arrival, mail selection, mail sending, mail deletion, account creation and account deletion.

8. A method for processing messages in a mail system, wherein: The message is a message in an email system, and the method comprises the steps of: In response to the user's operation on each mail function module in the mail system, generate a mail notification message; Searching for an observer queue corresponding to a message type of the generated email notification message, wherein each type of notification message corresponds to two observer queues, and the observer queues include one or more of an email receiving module, an email list interface, an email content interface, an account list interface, and an account deletion interface; Accessing one of the found observer queues, and using the observer in the observer queue to process the email notification message; Determine whether a new observer is generated in the process of processing the email notification message. If so, add the new observer to another observer queue that has not been accessed. If not, execute the step of accessing one of the observer queues that have been found and use the observer in the observer queue to process the email notification message.

9. A computing device comprising: at least one processor; as well as A memory storing program instructions, wherein the program instructions are configured to be executed by the at least one processor, and the program instructions include instructions for executing the method according to any one of claims 1 to 8.

10. A readable storage medium storing program instructions, when the program instructions are read and executed by a computing device, the computing device executes the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Message processing method, computing device and storage medium

    CN112711490A