41 lines
855 B
C++
41 lines
855 B
C++
/* -----------------------------------------------------------------------------
|
|
GSFramework
|
|
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
|
|
----------------------------------------------------------------------------- */
|
|
|
|
|
|
#ifndef __NTASKLOOP__
|
|
#define __NTASKLOOP__
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
#define StartTaskLoop(_CONDITION, _TIMEOUT)\
|
|
{\
|
|
using namespace GS;\
|
|
\
|
|
int ref_clock = Platform::Get().GetClock();\
|
|
bool timeout = false;\
|
|
\
|
|
while (_CONDITION)\
|
|
{\
|
|
if ((Platform::Get().GetClock() - ref_clock) >= _TIMEOUT)\
|
|
{\
|
|
timeout = true;\
|
|
break;\
|
|
}
|
|
|
|
#define EndTaskLoop } }
|
|
|
|
#define EndTaskLoopOnTimeout(_ON_TIMEOUT)\
|
|
}\
|
|
\
|
|
if (timeout)\
|
|
{\
|
|
_ON_TIMEOUT\
|
|
}\
|
|
}
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
#endif // __NTASKLOOP__
|