Qeventloop class Running Mechanism

Source: Internet
Author: User

 

QeventloopClass Running Mechanism

I will go to the competition tomorrow morning, so I will do it in advanceCodeAnalyze and take a rest early.

In yesterday's code analysis, we can see Qt For Windows This mechanism and its Implementation Code continue to be studied today. After detailed analysis Qeventdispatcherwin32 ClassSource codeThen, we find that this class corresponds Qeventloop It is associated with this class. First, check the document of this class. You can see that this class creates a local event loop for corresponding processing. Next, we recommend that you check the related Qiniacteventdispatcher Class, which acts as a managed Qt The interface of the event queue. Next, I found that Qeventdispatcherwin32 And many applicationsProgramThe thread class is mentioned in related classes, that is, we are now running the entire system in the main thread. It seems that it is time to figure out the Thread class.

The most common class is Qthreaddata Class, open the definition of this class, and find pointers to several familiar classes:

Qabstracteventdispatcher * eventdispatcher;

Qstack <qeventloop *> eventloops;

Qposteventlist posteventlist;

The first is the interface pointer of the event delivery class, the second is the pointer of the event loop class, and the above is the sending time list.

Pass Qstack As we can see, Qt Multiple event loops are supported. Qt The multi-threaded part is centrally managed.

Qthreaddata Class is mainly to save the necessary data for thread running. You need to find out the specific running process. Or from WIN32API Start, search Createthread Function, in Qaxservermain. cpp .

Static bool startmonitor ()

{

Dwthreadid = getcurrentthreadid ();

Heventshutdown = createevent (0, false, false, 0 );

If (heventshutdown = 0)

Return false;

DWORD dwthreadid;

Handle H = createthread (0, 0, monitorproc, 0, 0, & dwthreadid );

Return (H! = NULL );

}

QueryQtDocumentation, found Qaxserver Module , The system is onlyWindowsThe module provided by the system. It seems that the next step isQtThe multithreading part is studied. This is reserved for tomorrow's task. We have a rest today.

 

2009Year10Month30Friday21:11

 

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.