(iii) preliminary analysis of dispatch engine

Source: Internet
Author: User
Tags assert
Related UML:



The Cattempterengine implements two interfaces: Iqueueservicesink, Iattemperengine;
We learned from the previous analysis that the Iqueueservicesink interface was used to handle the data in Cqueueservice, and according to the UML above we can see that Cattemperengine is associated with a cqueueservice (or, directly, a Cqueueservice object, which is said to be a combination). In this case, the Cattemperengine exposed to the interface is only left iattemperenging.

1//Start service
2 virtual bool __cdecl startservice ();
3//Stop service
4 virtual bool __cdecl stopservice ();
5//Set up the network
6 virtual bool __cdecl setsocketengine (Iunknownex * Piunknownex);
7//Registered Hook
8 virtual bool __cdecl setattemperenginesink (Iunknownex * Piunknownex);
9//Get interface
virtual void * __cdecl Getqueueservice (const IID & Guid, DWORD dwqueryver);
This interface has two merits to discuss separately: Setsocketengine, Getqueueservice;
Setsocketengine, the following analysis will also appear, I think here is a design error led to the need to expose socket engine interface;
Getqueueservice design idea may be that each Iattemperengine interface has a cqueueservice behind, from the analysis can be seen in the future, this idea is the key to understanding the whole kernel. The dispatch engine should be a message rollup (messages generated from each engine) and then distributed to Iattemperenginesink. Because there's nothing in the code to see about Itimersink isocketsink and stuff like that,
The whole message is an engine-generated, and then posted to the specified Cqueueservice, and then summed up here to be distributed to iattemperenginesink out,,,

Look at the code that handles the data in Cattemperengine:
1//Queue Interface
2void __cdecl cattemperengine::onqueueservicesink (Word widentifier, void * pbuffer, Word wdatasize, DWORD dwinserttime)
3{
4//Kernel event
5 ASSERT (M_piattemperenginesink!=null);
6 switch (widentifier)
7 {
8 Case Event_timer://Timer Event
9 {
10//Efficacy parameters
One ASSERT (wdatasize==sizeof (nty_timerevent));
if (wdatasize!=sizeof (nty_timerevent)) return;
13
14//Processing messages
Nty_timerevent * ptimerevent= (nty_timerevent *) pbuffer;
M_piattemperenginesink->oneventtimer (Ptimerevent->wtimerid,ptimerevent->wbindparam);
17
return;
19}
Case event_database://Database Events
21 {
22//Efficacy parameters
ASSERT (wdatasize>=sizeof (nty_databaseevent));
if (wdatasize<sizeof (nty_databaseevent)) return;
25
26//Processing messages
Nty_databaseevent * pdatabaseevent= (nty_databaseevent *) pbuffer;
M_piattemperenginesink->oneventdatabase (Pdatabaseevent+1,wdatasize-sizeof (NTY_DataBaseEvent), PDataBaseEve NT);
29
return;
31}
Case EVENT_SOCKET_ACCEPT://Network Response Event
33 {
34//Efficacy size
ASSERT (wdatasize==sizeof (nty_socketacceptevent));
if (wdatasize!=sizeof (nty_socketacceptevent)) return;
37
38//Processing messages
Nty_socketacceptevent * psocketacceptevent= (nty_socketacceptevent *) pbuffer;
M_piattemperenginesink->oneventsocketaccept (psocketacceptevent);
41
return;
43}
Case Event_socket_read://Network Read events
45 {
46//Efficacy size
Nty_socketreadevent * psocketreadevent= (nty_socketreadevent *) pbuffer;
The ASSERT (wdatasize>=sizeof (nty_socketreadevent));
ASSERT (wdatasize== (sizeof (nty_socketreadevent) +psocketreadevent->wdatasize));
if (wdatasize<sizeof (nty_socketreadevent)) return;
wdatasize!= (sizeof (nty_socketreadevent) +psocketreadevent->wdatasize) return;
52
53

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.