[Home] [Prev] [Next] [Up]


YAAF_core: Threads

Thread support is a big hairy icky creature when developing an application framework: you have to deal with reentrancy, or at least warn the user that there are sections of the code which are not reentrant.

In addition, by default threads work differently in Microsoft Windows than from the Apple Macintosh with regards to event loop processing. That is, Microsoft Windows threads own the event loop of the windows they create. That means that another thread is unable to receive events for those windows.

The thread library here presents a way to encapsulate thread support. These utilities are also used to serialize access to portions of the application framework.

But because of the restrictions, thread support is really only invisioned as being used to provide auxiliary threads to do computations (such as a thread started to download mail from a TCP/IP POP3 server), and a main thread which does the event loop support.

Classes used to provide thread support are

XGThread

The thread wrapper class.

XGSemaphore

Semaphore encapsulation; this provides a way to serialize access to critical code to a limited number of threads.

XGCritical

A throw-safe mechanism for incrementing or decrementing the semaphore count.


[Home] [Prev] [Next] [Up]