version 0.1.10
[fms.git] / src / pthreadwrapper / thread.cpp
index 7a4e972..d08cf33 100644 (file)
@@ -9,6 +9,26 @@
 namespace PThread\r
 {\r
 \r
+void Sleep(const long ms)\r
+{\r
+       pthread_cond_t c;\r
+       pthread_mutex_t m;\r
+       timespec t;\r
+       timeb tb;\r
+\r
+       pthread_mutex_init(&m,NULL);\r
+       pthread_cond_init(&c,NULL);\r
+\r
+       ftime(&tb);\r
+\r
+       t.tv_sec=tb.time+(ms/1000);\r
+       t.tv_nsec=((1000000L)*(long)tb.millitm)+((1000000L)*(ms%1000));\r
+\r
+       pthread_mutex_lock(&m);\r
+       pthread_cond_timedwait(&c,&m,&t);\r
+       pthread_mutex_unlock(&m);\r
+}\r
+\r
 Thread::Thread()\r
 {\r
        m_running=false;\r