How to implements sleep() function in cocos2d-x?

In order to download data,I wrote a thread to download data from the server.
For some reason,I want the thread to keep running during the whole life of the program.
In fact there is a while loop in the thread,I need the while loop excute every 0.5second.
Here is the code below:
void* thread_func(void* arg)
{
CurlNetworkQueue* manager=(CurlNetworkQueue*)arg;
while(!thread_exit)
{
if(!manager~~>mTask.empty)
{
manager~~>mbDownloading=true;
curl_global_init(CURL_GLOBAL_ALL);
for(unsigned int i=0;imTask.size();i++)
{
CurlHttpRequest request=manager~~>mTask.front;
manager~~>mTask.pop();
manager~~>performDownload;
}
curl_global_cleanup;
manager~~>mbDownloading=false;
}
int i=0;
::Sleep(500);
}
return NULL;
}
The problem occurs cause the Sleep function.
I found that there is a “Sleep()”in Window.h on windows platform and a “sleep()” in unisd.h on linux platform.
But how can I find a similar one in cocos2d-x whitch need to be platform independent?
Please somebody help me.

OK,I got it finished by the two functions bellow:
void CommonFunc::thread_sleep(struct timespec *ti)
{
pthread_mutex_t mtx;
pthread_cond_t cnd;
pthread_mutex_init(&mtx, 0);
pthread_cond_init(&cnd, 0);
pthread_mutex_lock(&mtx);
pthread_cond_timedwait(&cnd, &mtx, ti);
pthread_mutex_unlock(&mtx);
pthread_cond_destroy(&cnd);
pthread_mutex_destroy(&mtx);
}

void CommonFunc::sleep(unsigned long secs,unsigned long msecs)
{
struct timeval tv;
struct timespec ti;
gettimeofday(&tv,NULL);
unsigned long offset=time(0);
int plat=CPlatformUtils::GetPlatform();
if(platWINDOWS)//windows
{
ti.tv_sec =offset+secs;
ti.tv_nsec=0;
}else if(platPLAT_ANDROID||platIPAD||platIPHONE)//Linux
{
ti.tv_sec=tv.tv_sec;
ti.tv_nsec=tv.tv_usec*1000+msecs*1000*1000;
}
thread_sleep(&ti);
}