first commit
This commit is contained in:
40
include/platform/async/task_loop.h
Normal file
40
include/platform/async/task_loop.h
Normal file
@ -0,0 +1,40 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
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__
|
||||
Reference in New Issue
Block a user