CN104216770B - A kind of browser message treatment method and device - Google Patents
A kind of browser message treatment method and device Download PDFInfo
- Publication number
- CN104216770B CN104216770B CN201410509529.6A CN201410509529A CN104216770B CN 104216770 B CN104216770 B CN 104216770B CN 201410509529 A CN201410509529 A CN 201410509529A CN 104216770 B CN104216770 B CN 104216770B
- Authority
- CN
- China
- Prior art keywords
- message
- queue
- messages
- taking
- message queue
- 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.)
- Expired - Fee Related
Links
Landscapes
- Information Transfer Between Computers (AREA)
Abstract
本发明公开了一种浏览器消息处理方法及装置,其中,所述方法包括:应用程序创建一消息队列;从操作系统为浏览器线程创建的消息队列中取出当前的所有消息,放入所述应用程序创建的消息队列中;判断所述取出的消息中是否存在符合预置条件的消息,如果存在,将所符合预置条件的消息进行顺序调整;按照所述应用程序创建的消息队列中各消息的顺序,将各个消息分发到浏览器相应的窗口进行处理。通过本发明,能够更加灵活地对浏览器的消息进行处理,以更好地实现浏览器的功能。
The invention discloses a browser message processing method and device, wherein the method includes: creating a message queue by an application program; taking out all current messages from the message queue created by the operating system for the browser thread, and putting them into the In the message queue created by the application program; judge whether there are messages that meet the preset conditions in the messages that are taken out, and if so, adjust the order of the messages that meet the preset conditions; The order of the messages, and distribute each message to the corresponding window of the browser for processing. Through the present invention, the messages of the browser can be processed more flexibly, so as to better realize the functions of the browser.
Description
技术领域technical field
本发明涉及Windows消息处理技术领域,特别是涉及一种浏览器消息处理方法及装置。The invention relates to the technical field of Windows message processing, in particular to a browser message processing method and device.
背景技术Background technique
Windows操作系统是一个消息(Message)驱动系统。Windows的消息提供了应用程序之间、应用程序与Windows操作系统之间进行通信的手段,应用程序想要实现的功能由消息来触发,并且靠对消息的响应和处理来完成。The Windows operating system is a message (Message) driven system. Windows messages provide a means of communication between applications and between applications and the Windows operating system. The functions that applications want to achieve are triggered by messages and completed by responding to and processing messages.
计算机的所有输入设备由Windows统一进行监控。当一个事件发生时,Windows先将输入的消息放入系统消息队列中,再将消息拷贝到应用程序相应的线程消息队列中。应用程序的消息处理程序将反复检测消息队列,并把检测到的消息进行转换后,分发到相应的窗口函数中,由相应的窗口函数对消息进行处理。这便是一个事件从发生至到达窗口函数进行处理所必须经历的过程。All input devices of the computer are uniformly monitored by Windows. When an event occurs, Windows first puts the input message into the system message queue, and then copies the message to the corresponding thread message queue of the application. The message processing program of the application program will repeatedly detect the message queue, and after converting the detected messages, distribute them to the corresponding window functions, and the corresponding window functions will process the messages. This is the process that an event must go through from its occurrence to its arrival at the window function for processing.
然而,在Windows操作系统中,消息并非是抢占性的,也即,无论事件的缓急,总是按照到达的先后依次进行处理(一些系统消息除外),这样可能会造成一些不利的影响。例如,可能会使一些实时外部事件得不到及时处理,影响应用程序对具体功能的实现。例如,对于浏览器而言,该应用程序时一个需要频繁与用户进行交互的网页浏览工具,当用户触发一些外部事件之后,如果迟迟得到不处理,可能会使得一些操作失效,等等。However, in the Windows operating system, messages are not preemptive, that is, regardless of the priority of events, they are always processed in the order of arrival (except for some system messages), which may cause some adverse effects. For example, some real-time external events may not be processed in time, affecting the realization of specific functions of the application. For example, for a browser, the application is a web browsing tool that requires frequent interaction with the user. When the user triggers some external events, if they are not processed for a long time, some operations may be invalidated, and so on.
因此,迫切需要本领域技术人员解决的技术问题就在于,如何能更加灵活地对浏览器的消息进行处理,以更好地实现浏览器的功能。Therefore, a technical problem that urgently needs to be solved by those skilled in the art is how to process browser messages more flexibly so as to better realize browser functions.
发明内容Contents of the invention
本发明提供了一种浏览器消息处理方法及装置,能够更加灵活地对浏览器的消息进行处理,以更好地实现浏览器的功能。The invention provides a browser message processing method and device, which can process browser messages more flexibly to better realize browser functions.
本发明提供了如下方案:The present invention provides following scheme:
一种浏览器消息处理方法,其特征在于,包括:A browser message processing method, characterized in that, comprising:
应用程序创建一消息队列;The application creates a message queue;
从操作系统为浏览器线程创建的消息队列中取出当前的所有消息,放入所述应用程序创建的消息队列中;Take out all current messages from the message queue created by the operating system for the browser thread, and put them into the message queue created by the application program;
判断所述取出的消息中是否存在符合预置条件的消息,如果存在,将所符合预置条件的消息进行顺序调整;judging whether there are messages meeting the preset conditions in the fetched messages, and if so, adjusting the order of the messages meeting the preset conditions;
按照所述应用程序创建的消息队列中各消息的顺序,将各个消息分发到浏览器相应的窗口进行处理。According to the order of the messages in the message queue created by the application, the messages are distributed to the corresponding windows of the browser for processing.
优选地,上述方法还包括:Preferably, the above method also includes:
从操作系统为浏览器线程创建的消息队列中取出当前的所有消息之后,将所述取出的消息从所述操作系统创建的消息队列中清除。After fetching all current messages from the message queue created by the operating system for the browser thread, clear the fetched messages from the message queue created by the operating system.
优选地,所述判断所述取出的消息中是否存在符合预置条件的消息,如果存在,将所符合预置条件的消息进行顺序调整包括:Preferably, the judging whether there are messages meeting the preset conditions in the fetched messages, and if so, adjusting the order of the messages meeting the preset conditions includes:
判断所述取出的消息中是否存在需要由当前处于焦点的窗口处理的消息,如果存在,则将该消息调整到消息队列的前端。Judging whether there is a message that needs to be processed by the window currently in focus among the fetched messages, and if so, adjusting the message to the front end of the message queue.
优选地,所述判断所述取出的消息中是否存在符合预置条件的消息,如果存在,将所符合预置条件的消息进行顺序调整包括:Preferably, the judging whether there are messages meeting the preset conditions in the fetched messages, and if so, adjusting the order of the messages meeting the preset conditions includes:
判断所述取出的消息中是否存在与用户交互相关的消息,如果存在,则将该消息调整到消息队列的前端。It is judged whether there is a message related to user interaction among the fetched messages, and if so, the message is adjusted to the front end of the message queue.
优选地,所述判断所述取出的消息中是否存在符合预置条件的消息,如果存在,将所符合预置条件的消息进行顺序调整包括:Preferably, the judging whether there are messages meeting the preset conditions in the fetched messages, and if so, adjusting the order of the messages meeting the preset conditions includes:
判断所述取出的消息中是否存在需要在第一消息之前处理的第二消息,如果存在,则将所述第二消息调整到所述第一消息之前。Judging whether there is a second message that needs to be processed before the first message among the fetched messages, and if so, adjusting the second message to be before the first message.
一种消息处理装置,其特征在于,包括:A message processing device, characterized in that it includes:
队列创建单元,用于应用程序创建一消息队列;A queue creation unit, used for an application to create a message queue;
消息取出单元,用于从操作系统为浏览器线程创建的消息队列中取出当前的所有消息,放入所述应用程序创建的消息队列中;The message fetching unit is used to fetch all current messages from the message queue created by the operating system for the browser thread, and put them into the message queue created by the application program;
顺序调整单元,用于判断所述取出的消息中是否存在符合预置条件的消息,如果存在,将所符合预置条件的消息进行顺序调整;A sequence adjustment unit, configured to determine whether there are messages that meet the preset conditions in the fetched messages, and if so, adjust the order of the messages that meet the preset conditions;
消息分发单元,用于按照所述应用程序创建的消息队列中各消息的顺序,将各个消息分发到浏览器相应的窗口进行处理。The message distribution unit is configured to distribute each message to a corresponding window of the browser for processing according to the sequence of the messages in the message queue created by the application program.
优选地,上述消息处理装置还包括:Preferably, the above message processing device further includes:
清除单元,用于从操作系统为浏览器线程创建的消息队列中取出当前的所有消息之后,将所述取出的消息从所述操作系统创建的消息队列中清除。The clearing unit is configured to, after taking out all current messages from the message queue created by the operating system for the browser thread, clear the taken out messages from the message queue created by the operating system.
优选地,所述顺序调整单元包括:Preferably, the sequence adjustment unit includes:
第一调整子单元,用于判断所述取出的消息中是否存在需要由当前处于焦点的窗口处理的消息,如果存在,则将该消息调整到消息队列的前端。The first adjusting subunit is configured to judge whether there is a message that needs to be processed by the window currently in focus among the fetched messages, and if so, adjust the message to the front end of the message queue.
优选地,所述顺序调整单元包括:Preferably, the sequence adjustment unit includes:
第二调整子单元,用于判断所述取出的消息中是否存在与用户交互相关的消息,如果存在,则将该消息调整到消息队列的前端。The second adjustment subunit is configured to judge whether there is a message related to user interaction among the retrieved messages, and if there is, adjust the message to the front end of the message queue.
优选地,所述顺序调整单元包括:Preferably, the sequence adjustment unit includes:
第三调整子单元,用于判断所述取出的消息中是否存在需要在第一消息之前处理的第二消息,如果存在,则将所述第二消息调整到所述第一消息之前。The third adjusting subunit is configured to judge whether there is a second message that needs to be processed before the first message among the fetched messages, and if so, adjust the second message before the first message.
根据本发明提供的具体实施例,本发明达到了以下技术效果:According to the specific embodiments provided by the invention, the present invention has achieved the following technical effects:
通过本发明实施例,由于应用程序可以自行创建消息队列,并将操作系统为浏览器线程创建的消息队列中的当前消息取出,放入该自行创建的消息队列中,从而使得消息的先后执行顺序是可以调整的,而不是一律地按照操作系统中规定的先到先处理的原则,这样,可以更加灵活地对消息队列中的消息进行处理。例如,可以使得一些实时外部事件得到及时处理,并且,如果出现有些在后到达的消息必须赶在另一些在先到达的消息之前处理才能达到预定效果的情况,则可以将在后到达的消息提到在先到达的消息之前,从而达到预定效果。Through the embodiment of the present invention, because the application program can create a message queue by itself, and take out the current message in the message queue created by the operating system for the browser thread, and put it into the self-created message queue, so that the sequence of message execution It can be adjusted, instead of following the first-come-first-handled principle stipulated in the operating system, so that the messages in the message queue can be processed more flexibly. For example, some real-time external events can be processed in time, and if some messages that arrive later must be processed before other messages that arrive earlier to achieve the intended effect, the messages that arrive later can be processed in advance. Before the message that arrives earlier, so as to achieve the intended effect.
附图说明Description of drawings
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the accompanying drawings required in the embodiments. Obviously, the accompanying drawings in the following description are only some of the present invention. Embodiments, for those of ordinary skill in the art, other drawings can also be obtained based on these drawings without any creative effort.
图1是本发明实施例提供的方法的流程图;Fig. 1 is the flowchart of the method provided by the embodiment of the present invention;
图2是本发明实施例提供的装置的示意图。Fig. 2 is a schematic diagram of a device provided by an embodiment of the present invention.
具体实施方式Detailed ways
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员所获得的所有其他实施例,都属于本发明保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some, not all, embodiments of the present invention. All other embodiments obtained by persons of ordinary skill in the art based on the embodiments of the present invention belong to the protection scope of the present invention.
参见图1,本发明实施例首先提供了一种浏览器消息处理方法,该方法可以应用于一应用程序中(该应用程序可以是为实现该消息处理功能开发的一种应用程序,也可以是在已有浏览器基础上增加该消息处理功能,等等),具体实现时,该方法可以包括以下步骤:Referring to Fig. 1, the embodiment of the present invention firstly provides a kind of browser message processing method, and this method can be applied in an application program (this application program can be a kind of application program developed for realizing this message processing function, also can be Adding the message processing function on the basis of the existing browser, etc.), during specific implementation, the method may include the following steps:
S101:应用程序创建一消息队列;S101: The application program creates a message queue;
该消息队列是由应用程序自己创建的,因此,应用程序可以自行决定其中的消息以怎样的顺序进行排列,还可以自行对顺序进行调整。The message queue is created by the application program itself, so the application program can decide the order in which the messages are arranged, and can also adjust the order by itself.
S102:从操作系统为浏览器线程创建的消息队列中取出当前的所有消息,放入所述应用程序创建的消息队列中;S102: Take out all current messages from the message queue created by the operating system for the browser thread, and put them into the message queue created by the application program;
为了更好地理解该步骤,下面首先对操作系统中的消息处理过程进行简单地介绍。一般而言,一个消息(以外部输入消息为例)从产生到最后被处理会经历以下过程:(1)当鼠标或者键盘有动作时,设备驱动将输入操作转换为消息并将它放入到系统消息队列中;(2)操作系统每次从系统消息队列中移出一个消息时,会判断这个消息属于哪个目标窗口,然后将其分发到创建目标窗口的线程的消息队列里,换言之,线程的消息队列为其创建的窗口接收所有鼠标和键盘消息;(3)线程从它的消息队列中移出消息并指引系统将这些消息分发到正确的窗口来对消息进行处理。可见,操作系统会创建两种消息队列,一种是系统消息队列,所有消息都会先放入这个系统消息队列;另一种是线程的消息队列,需要由某线程创建的窗口处理的所有消息会放入该线程的消息队列中。In order to better understand this step, the message processing process in the operating system is briefly introduced below. Generally speaking, a message (take an external input message as an example) will go through the following process from generation to final processing: (1) When the mouse or keyboard has an action, the device driver converts the input operation into a message and puts it into (2) Every time the operating system removes a message from the system message queue, it will judge which target window the message belongs to, and then distribute it to the message queue of the thread that created the target window. The window created for it by the message queue receives all mouse and keyboard messages; (3) the thread removes messages from its message queue and instructs the system to distribute these messages to the correct window to process the message. It can be seen that the operating system will create two message queues, one is the system message queue, and all messages will be put into this system message queue first; the other is the thread message queue, and all messages that need to be processed by a window created by a thread will be into the thread's message queue.
相应的,对于在操作系统中运行的浏览器程序而言,操作系统也会为浏览器的线程创建消息队列,当从系统消息队列中取出的消息属于浏览器的某线程时,就会将该消息放入到该线程的消息队列中。本发明实施例就是将已经分发到浏览器线程的消息队列中的线程取出来,存放到应用程序自己创建的消息队列中。Correspondingly, for the browser program running in the operating system, the operating system will also create a message queue for the browser thread, and when the message taken out from the system message queue belongs to a certain thread of the browser, it will The message is put into the thread's message queue. The embodiment of the present invention is to take out the threads that have been distributed to the message queue of the browser thread, and store them in the message queue created by the application program itself.
需要说明的是,浏览器线程的消息队列中的消息,除了包括上述外部输入的消息(也即由鼠标键盘等产生的消息)之外,还可能包括系统消息(也即由操作系统产生的消息),此外,还可能包括浏览器自身产生的消息,例如,某操作可能并不是立即处理,此时,可以通过产生消息的方式进行延后处理,也即,先将该消息放到消息队列中进行排队,从而延后该消息的处理时间;再或者有些操作可能是需要跨线程执行的,此时,也可以先放到消息队列中,然后分发到对应的线程消息队列中,等等。本发明实施例中,从浏览器线程的消息队列中取出当前消息时,可以包括上述所有类型的消息,也即,所有消息,无论其来自于外部输入还是操作系统还是浏览器自身,都可以将其取出,放入到应用程序自行创建的消息队列中,以便对消息的顺序进行调整。当然,一些系统消息的执行顺序可能是不允许调整的,此时,可以不对这种系统消息进行顺序调整。It should be noted that the messages in the message queue of the browser thread may include system messages (that is, messages generated by the operating system) in addition to the above-mentioned externally input messages (that is, messages generated by the mouse and keyboard, etc.). ), in addition, it may also include messages generated by the browser itself. For example, an operation may not be processed immediately. At this time, the delayed processing can be performed by generating a message, that is, the message is first put in the message queue Queue to delay the processing time of the message; or some operations may need to be executed across threads. At this time, it can also be placed in the message queue first, and then distributed to the corresponding thread message queue, and so on. In the embodiment of the present invention, when the current message is taken out from the message queue of the browser thread, all the above-mentioned types of messages can be included, that is, all messages, no matter they come from external input, the operating system or the browser itself, can be It is taken out and put into the message queue created by the application program itself, so as to adjust the order of the messages. Of course, the execution order of some system messages may not allow adjustment, and at this time, the order adjustment of such system messages may not be performed.
另外需要说明的是,具体在从浏览器线程的消息队列中取出消息时,可以利用操作系统提供的API(Application Programming Interface,应用程序编程接口)函数等方式来进行。例如,可以直接使用以下API函数:PeekMessage。In addition, it should be noted that when the message is retrieved from the message queue of the browser thread, an API (Application Programming Interface, application programming interface) function provided by the operating system can be used to perform the process. For example, the following API function can be used directly: PeekMessage.
当然,为了避免程序运行过程中出现错误,在从操作系统创建的消息队列中取出当前的消息之后,还可以将取出的消息从所述操作系统创建的消息队列中清除。Of course, in order to avoid errors during the running of the program, after the current message is fetched from the message queue created by the operating system, the fetched message can also be cleared from the message queue created by the operating system.
S103:判断所述取出的消息中是否存在符合预置条件的消息,如果存在,将所符合预置条件的消息进行顺序调整;S103: Judging whether there is a message meeting the preset condition among the fetched messages, and if so, adjusting the order of the messages meeting the preset condition;
具体对消息进行调整的依据可以根据实际应用中的需要来确定,例如,可以认为一些与用户交互相关的操作产生的消息是需要优先处理的,此时,就可以将这样的消息放入到消息队列中比较靠前的位置。又如,假如用户在看视频,那么视频相关的操作就可能需要优先操作,此时,就可以将这种操作对应的消息放入到消息队列中比较靠前的位置。再如,如果用户在看视频时,又进行了其他操作,于是就可以认为用户的这个操作对应的消息需要插队、提前处理,等等。此外,还可以判断各个消息是否需要由当前处于焦点的窗口处理,如果是,则可以将该消息的顺序提前。再者,有些消息(尤其是由浏览器自身产生的消息)可能是需要在另一消息之前执行的,此时,还可以将该消息调整到该另一消息之前,等等。The specific basis for adjusting the message can be determined according to the needs of the actual application. For example, it can be considered that some messages generated by operations related to user interaction need to be processed first. At this time, such messages can be put into the message The higher position in the queue. For another example, if the user is watching a video, video-related operations may need to be prioritized. At this time, the message corresponding to this operation can be put into a relatively front position in the message queue. For another example, if the user performs other operations while watching a video, it can be considered that the message corresponding to the user's operation needs to be queued, processed in advance, and so on. In addition, it can also be judged whether each message needs to be processed by the window currently in focus, and if so, the order of the message can be advanced. Furthermore, some messages (especially messages generated by the browser itself) may need to be executed before another message. At this time, the message can also be adjusted before the other message, and so on.
需要说明的是,操作系统会对每个消息进行编号,每个消息具有自己的ID,消息中可以包含窗口句柄、消息类型等信息,通过系统的API函数可以获知这些信息(例如,通过GetInputState可以检查是否有键盘或鼠标消息在线程消息队列中,通过GetQueueStatus可以检查消息队列中某一类型的消息,等等)根据这些信息可以知悉每个消息分别需要由哪个窗口进行处理以及消息对应的操作等等,进而就可以根据预先设定的规则,来确定各个消息在消息队列中的顺序。例如,发现取出的某消息对应的操作是需要由某视频播放窗口处理的,并且预先设置这类消息的优先级比较高,因此,就可以将该消息放在消息队列中比较靠前的位置,甚至可以放在首位,等等。It should be noted that the operating system will number each message, and each message has its own ID. The message can include information such as window handle and message type, which can be obtained through the API functions of the system (for example, through GetInputState, you can Check whether there is a keyboard or mouse message in the thread message queue, you can check a certain type of message in the message queue through GetQueueStatus, etc.) According to this information, you can know which window each message needs to be processed and the corresponding operation of the message, etc. etc., and then the order of each message in the message queue can be determined according to the preset rules. For example, it is found that the operation corresponding to a certain message needs to be processed by a certain video playback window, and the priority of this type of message is preset to be relatively high, so the message can be placed at a relatively high position in the message queue. Maybe even in the first place, etc.
S104:按照所述应用程序创建的消息队列中各消息的顺序,将各个消息分发到浏览器相应的窗口进行处理。S104: According to the sequence of the messages in the message queue created by the application program, distribute each message to a corresponding window of the browser for processing.
由于在应用程序自行创建的消息队列中,各个消息已经重新进行了调整,因此,就可以按照调整之后的顺序,对各个消息进行分发处理。具体的,由于在步骤S102中是从浏览器线程的消息队列中取出的消息,因此在分发处理时,可以直接将消息分发到对应的浏览器窗口,由对应的窗口对消息进行处理即可。也就是说,相当于是在操作系统将系统队列中的消息分发到具体的浏览器线程消息队列之后,并不是由线程自己将消息分发到具体的窗口,而是由具有本发明实施例所述的消息处理功能的应用程序,代替各个具体的线程完成该分发工作。具体实现时,在代替具体的线程完成消息分发的操作时,同样可以由该具有消息处理功能的应用程序使用操作系统提供的API函数来实现(该API函数可以是:DispatchMessage)。Since each message has been re-adjusted in the message queue created by the application program, each message can be distributed and processed according to the adjusted order. Specifically, since the message is taken out from the message queue of the browser thread in step S102, the message can be directly distributed to the corresponding browser window during distribution processing, and the corresponding window can process the message. That is to say, it is equivalent to that after the operating system distributes the messages in the system queue to specific browser thread message queues, it is not the thread itself that distributes the messages to the specific windows, but the message queue described in the embodiments of the present invention. The application program of the message processing function completes the distribution work instead of each specific thread. During specific implementation, when the operation of distributing messages is completed instead of a specific thread, it can also be implemented by the application program with message processing function using the API function provided by the operating system (the API function can be: DispatchMessage).
总之,通过本发明实施例提供的消息处理方法,由于应用程序可以自行创建消息队列,并将操作系统为浏览器线程创建的消息队列中的当前消息取出,放入该自行创建的消息队列中,从而使得消息的先后执行顺序是可以调整的,而不是一律地按照操作系统中规定的先到先处理的原则,这样,可以更加灵活地对消息队列中的消息进行处理。例如,可以使得一些实时外部事件得到及时处理,并且,如果出现有些在后到达的消息必须赶在另一些在先到达的消息之前处理才能达到预定效果的情况,则可以将在后到达的消息提到在先到达的消息之前,从而达到预定效果。In short, through the message processing method provided by the embodiment of the present invention, since the application program can create a message queue by itself, and take out the current message in the message queue created by the operating system for the browser thread, and put it into the self-created message queue, Therefore, the execution order of the messages can be adjusted, instead of following the first-come-first-processed principle specified in the operating system, so that the messages in the message queue can be processed more flexibly. For example, some real-time external events can be processed in time, and if some messages that arrive later must be processed before other messages that arrive earlier to achieve the intended effect, the messages that arrive later can be processed in advance. Before the message that arrives earlier, so as to achieve the intended effect.
与本发明实施例提供的浏览器消息处理方法相对应,本发明实施例还提供了一种浏览器消息处理装置,同样,该装置应用于一应用程序中,参见图2,该装置包括以下单元:Corresponding to the browser message processing method provided in the embodiment of the present invention, the embodiment of the present invention also provides a browser message processing device. Similarly, the device is applied to an application program, as shown in FIG. 2, and the device includes the following units :
队列创建单元201,用于应用程序创建一消息队列;A queue creation unit 201, used for an application to create a message queue;
消息取出单元202,用于从操作系统为浏览器线程创建的消息队列中取出当前的所有消息,放入所述应用程序创建的消息队列中;The message fetching unit 202 is used to fetch all current messages from the message queue created by the operating system for the browser thread, and put them into the message queue created by the application program;
顺序调整单元203,用于判断所述取出的消息中是否存在符合预置条件的消息,如果存在,将所符合预置条件的消息进行顺序调整;A sequence adjustment unit 203, configured to judge whether there is a message meeting a preset condition among the fetched messages, and if so, adjust the sequence of the message meeting the preset condition;
消息分发单元204,用于按照所述应用程序创建的消息队列中各消息的顺序,将各个消息分发到浏览器相应的窗口进行处理。The message distribution unit 204 is configured to distribute each message to a corresponding window of the browser for processing according to the order of the messages in the message queue created by the application program.
当然,为了避免程序运行过程中出现错误,在从操作系统创建的消息队列中取出当前的消息之后,还可以将取出的消息从所述操作系统创建的消息队列中清除。具体实现时,该装置还可以包括:Of course, in order to avoid errors during the running of the program, after the current message is fetched from the message queue created by the operating system, the fetched message can also be cleared from the message queue created by the operating system. During specific implementation, the device may also include:
清除单元,用于从操作系统为浏览器线程创建的消息队列中取出当前的所有消息之后,将所述取出的消息从所述操作系统创建的消息队列中清除。The clearing unit is configured to, after taking out all current messages from the message queue created by the operating system for the browser thread, clear the taken out messages from the message queue created by the operating system.
其中,具体实现时,顺序调整单元203具体可以包括:Wherein, during specific implementation, the sequence adjustment unit 203 may specifically include:
第一调整子单元,用于判断所述取出的消息中是否存在需要由当前处于焦点的窗口处理的消息,如果存在,则将该消息调整到消息队列的前端。The first adjusting subunit is configured to judge whether there is a message that needs to be processed by the window currently in focus among the fetched messages, and if so, adjust the message to the front end of the message queue.
或者,顺序调整单元203具体也可以包括:Alternatively, the order adjusting unit 203 may specifically include:
第二调整子单元,用于判断所述取出的消息中是否存在与用户交互相关的消息,如果存在,则将该消息调整到消息队列的前端。The second adjustment subunit is configured to judge whether there is a message related to user interaction among the retrieved messages, and if there is, adjust the message to the front end of the message queue.
再者,顺序调整单元203具体还可以包括:Furthermore, the sequence adjustment unit 203 may specifically include:
第三调整子单元,用于判断所述取出的消息中是否存在需要在第一消息之前处理的第二消息,如果存在,则将所述第二消息调整到所述第一消息之前。The third adjusting subunit is configured to judge whether there is a second message that needs to be processed before the first message among the fetched messages, and if so, adjust the second message before the first message.
通过本发明实施例提供的消息处理装置,由于应用程序可以自行创建消息队列,并将操作系统为浏览器线程创建的消息队列中的当前消息取出,放入该自行创建的消息队列中,从而使得消息的先后执行顺序是可以调整的,而不是一律地按照操作系统中规定的先到先处理的原则,这样,可以更加灵活地对消息队列中的消息进行处理。例如,可以使得一些实时外部事件得到及时处理,并且,如果出现有些在后到达的消息必须赶在另一些在先到达的消息之前处理才能达到预定效果的情况,则可以将在后到达的消息提到在先到达的消息之前,从而达到预定效果。Through the message processing device provided by the embodiment of the present invention, since the application program can create a message queue by itself, and take out the current message in the message queue created by the operating system for the browser thread, and put it into the self-created message queue, so that The execution sequence of messages can be adjusted, instead of following the first-come-first-handled principle stipulated in the operating system, so that the messages in the message queue can be processed more flexibly. For example, some real-time external events can be processed in time, and if some messages that arrive later must be processed before other messages that arrive earlier to achieve the intended effect, the messages that arrive later can be processed in advance. Before the message that arrives earlier, so as to achieve the intended effect.
通过以上的实施方式的描述可知,本领域的技术人员可以清楚地了解到本发明可借助软件加必需的通用硬件平台的方式来实现。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品可以存储在存储介质中,如ROM/RAM、磁碟、光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例或者实施例的某些部分所述的方法。It can be seen from the above description of the implementation manners that those skilled in the art can clearly understand that the present invention can be implemented by means of software plus a necessary general hardware platform. Based on this understanding, the essence of the technical solution of the present invention or the part that contributes to the prior art can be embodied in the form of software products, and the computer software products can be stored in storage media, such as ROM/RAM, disk , CD, etc., including several instructions to make a computer device (which may be a personal computer, server, or network device, etc.) execute the methods described in various embodiments or some parts of the embodiments of the present invention.
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于装置或系统实施例而言,由于其基本相似于方法实施例,所以描述得比较简单,相关之处参见方法实施例的部分说明即可。以上所描述的装置及系统实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性劳动的情况下,即可以理解并实施。Each embodiment in this specification is described in a progressive manner, the same and similar parts of each embodiment can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device or system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and for relevant parts, refer to part of the description of the method embodiments. The device and system embodiments described above are only illustrative, and the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, It can be located in one place, or it can be distributed to multiple network elements. Part or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. It can be understood and implemented by those skilled in the art without creative effort.
以上对本发明所提供的一种浏览器消息处理方法及装置,进行了详细介绍,本文中应用了具体个例对本发明的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本发明的方法及其核心思想;同时,对于本领域的一般技术人员,依据本发明的思想,在具体实施方式及应用范围上均会有改变之处。综上所述,本说明书内容不应理解为对本发明的限制。The above is a detailed introduction of a browser message processing method and device provided by the present invention. In this paper, specific examples are used to illustrate the principle and implementation of the present invention. The description of the above embodiments is only used to help understand the present invention. The method of the invention and its core idea; at the same time, for those of ordinary skill in the art, according to the idea of the invention, there will be changes in the specific implementation and application range. In summary, the contents of this specification should not be construed as limiting the present invention.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410509529.6A CN104216770B (en) | 2011-12-28 | 2011-12-28 | A kind of browser message treatment method and device |
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201110448569.0A CN102541641B (en) | 2011-12-28 | 2011-12-28 | Method and device for browser message processing |
CN201410509529.6A CN104216770B (en) | 2011-12-28 | 2011-12-28 | A kind of browser message treatment method and device |
Related Parent Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201110448569.0A Division CN102541641B (en) | 2011-12-28 | 2011-12-28 | Method and device for browser message processing |
Publications (2)
Publication Number | Publication Date |
---|---|
CN104216770A CN104216770A (en) | 2014-12-17 |
CN104216770B true CN104216770B (en) | 2018-12-04 |
Family
ID=52098295
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201410509529.6A Expired - Fee Related CN104216770B (en) | 2011-12-28 | 2011-12-28 | A kind of browser message treatment method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104216770B (en) |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2011001210A1 (en) * | 2009-06-29 | 2011-01-06 | Nokia Corporation | Resource allocation |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
DE602004001666T2 (en) * | 2004-04-08 | 2006-11-30 | Research In Motion Ltd., Waterloo | Priority based re-ordering in a message send queue |
CN101068222A (en) * | 2007-01-15 | 2007-11-07 | 腾讯科技(深圳)有限公司 | Method and device for processing information |
CN101408851A (en) * | 2007-10-09 | 2009-04-15 | 鸿富锦精密工业(深圳)有限公司 | System and method for emergently stopping application program |
CN101996099A (en) * | 2010-11-17 | 2011-03-30 | 山东中创软件工程股份有限公司 | Method and system for processing information |
-
2011
- 2011-12-28 CN CN201410509529.6A patent/CN104216770B/en not_active Expired - Fee Related
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2011001210A1 (en) * | 2009-06-29 | 2011-01-06 | Nokia Corporation | Resource allocation |
Also Published As
Publication number | Publication date |
---|---|
CN104216770A (en) | 2014-12-17 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN102591658B (en) | A kind of message treatment method and device | |
US9800691B2 (en) | Stream processing using a client-server architecture | |
US10769026B2 (en) | Dynamically pausing large backups | |
US20100179994A1 (en) | Preserving message order using a message ordering manager | |
TW201638779A (en) | Method, device, system, and electronic facility for resource management of virtual host | |
US8997060B2 (en) | Parallel program analysis and branch prediction | |
US20120023359A1 (en) | Method, apparatus and computer program for processing invalid data | |
CN105262680A (en) | Multi-threaded NAS Gateway applied to cloud storage system | |
CN102541641B (en) | Method and device for browser message processing | |
CN104881307B (en) | Method and device for realizing downloading | |
CN104216770B (en) | A kind of browser message treatment method and device | |
CN105450694A (en) | Redirecting the service request to destination address; | |
CN104899088B (en) | A kind of message treatment method and device | |
US20190253302A1 (en) | System and method for managing content | |
WO2016074493A1 (en) | Control method and apparatus of media object display and media object display system | |
US8990332B2 (en) | Performance optimization of a publish operation | |
EP3278205B1 (en) | View activation via hit testing in an asynchronous windowing system | |
JP2009157662A (en) | Database management apparatus, database management method, and database management program | |
JP2018005768A (en) | Job scheduler test program, job scheduler test method and parallel processor | |
CN105242915A (en) | Data operation processing method and apparatus | |
EP3396553B1 (en) | Method and device for processing data after restart of node | |
CN107465743B (en) | Method and device for processing request | |
CN105653386A (en) | Process breakdown processing method and terminal equipment | |
WO2013097663A1 (en) | Message processing method and device | |
CN110020275B (en) | Method and system for loading gift panel in live broadcast |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20181204 Termination date: 20211228 |