Click here to Skip to main content
15,886,806 members
Articles / Programming Languages / C++

Create Cross-platform Thread-Independent Event Loops

Rate me:
Please Sign up or sign in to vote.
4.89/5 (5 votes)
12 May 20076 min read 45.7K   687   28  
This article discloses what is behind the GetMessage() and PostThreadMessage() Windows API, and implements them on Linux and Windows platforms using basic operation system functions.
#ifndef SINGLE_STATE_H
#define SINGLE_STATE_H

#include "sme.h"


#ifdef __cplusplus
extern "C" {
#endif

#if SME_CPP

class CSingleState: public SME_APP_T
{
public:
	CSingleState(const char* _sAppName, SME_STATE_T *_pRoot):SME_APP_T(_sAppName, _pRoot) {
	};

SME_BEGIN_CLASS_MEMBER_DECLARE(SingleState)
SME_END_CLASS_MEMBER_DECLARE

#else
/* Pre-declare states that are referenced before they are defined */
SME_BEGIN_STATE_DECLARE(SingleState)
SME_END_STATE_DECLARE

#endif


/*{{SME_BEGIN_EVENT_HANDLER(Player)*/
int SingleStateEntry(SME_APP_T *pApp, SME_EVENT_T *pEvent);
int SingleStateExit(SME_APP_T *pApp, SME_EVENT_T *pEvent);
/*}}SME_END_EVENT_HANDLER*/

#if SME_CPP

};

#endif

#ifdef __cplusplus
}
#endif

#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior)
United States United States
Alex "Question is more important than the answer."

Comments and Discussions